Hash Generation Logic

Use this logic to generate an SHA256 hash of base64 encoded request.

public static string GetSHAGenerated(string request, string secureSecret)
{
string hexHash = String.Empty;

byte[] convertedHash = new byte[secureSecret.Length / 2];
for (int i = 0; i < secureSecret.Length / 2; i++)
    {
convertedHash[i] = (byte)int.Parse(secureSecret.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
    }


using (HMACSHA256 hasher = new HMACSHA256(convertedHash))
    {
byte[] hashValue = hasher.ComputeHash(Encoding.UTF8.GetBytes(request));
foreach (byte b in hashValue)
        {
hexHash += b.ToString("X2");
        }
    }

return hexHash;
}