using System.Collections.Generic;
using System.Security.Cryptography;
public static void Main()
String pubickey = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAw3D1U/KZR0iVmJJ5R6UxqghdvMUCFoRvuG3CSYvI4OAJdjdo9k28Twe2rjOQJMguiPHz7a7V2ZqON1cUiVJ3LjZ/hDDfstajgm91pje04/AP95Io9B/I8g6Mn8B4iZLft/AH3c0AOZMdU9tPf9Y5Xq/dEzMTyIxOOiyS+6kqin4kgMc8uAE4EdOwraRMOYVs1VaHDqp3KoaNVj5X96guSdWHsJ3MDxdi1EqTFBvyCWqMPU6PjJjCeokJc/sGIhnWbtDaQ+/+bXW0uAlqBfY9O7q5DbXOKllQoV5+ctyZANegyhbLHqc4UKkL4mWSaqvm9jdxAe4CGo0olLYpZjzWamnupE0HepxAM9fnpUnNo+DA2c+bhlHy1XCoZlQneyPLelqeXQHHKEweW3fIqTlPYkz6ijBFXtcN/ybKVDHV/edOjTqbdi3VsBDsxncqa6q1mNKge63+esHWHuk+ID0YYWVLm4NsKDvy0XgiPZE/mdDLdMse/twpvsRyND42jKt+TzKMw4xoLL6gDQiDJrUe3tFYI85J9t7fxa2oB8ygEjqdr1fLRQWV2ZrgMR+W+cJKyWhvITr0nFuFeTJtqLxBMp2TkElnmN1taZ6uaeFz7InKJs+Jf9D3ihwrZnylR1jJshV//eQ/NTfkT027jAFo8OAwws8VGvJTNAsMto9ydYcCAwEAAQ==";
String req = "{\"criteria\": {\"@class\": \"za.co.magnabc.malawi.financial.PaymentReferenceCriteria\",\"paymentReference\": {\"@class\":\"za.co.magnabc.financial.TransactionReferenceNumber\",\"referenceNumber\":\"20200603000016\"}}}";
Console.WriteLine(Encode(req, pubickey));
public static string Encode(string input, string publicKey)
HMACSHA384 myhmacsha1 = new HMACSHA384(Encoding.ASCII.GetBytes(publicKey));
byte[] byteArray = Encoding.ASCII.GetBytes(input);
MemoryStream stream = new MemoryStream(byteArray);
return myhmacsha1.ComputeHash(stream).Aggregate("", (s, e) => s + String.Format("{0:x2}",e), s => s );