I am attempting to use this process to hash data in custom policy: https://learn.microsoft.com/en-us/azure/active-directory-b2c/general-transformations#hash
I need to hash data the same way in c# that will be sent as claims to the policy, and then will use custom policy to hash the same data, and then will compare in custom policy that the hashes match. However, when I hash the data using c# using the following code snipet and then try to hash the data in the policy, the hashes are not matching. Im looking for the method I can use in C# that the custom policy is using to hash the data?
var saltedClaim = string.Concat(text, salt);
byte[] saltedClaimAsBytes = Encoding.UTF8.GetBytes(saltedClaim);
byte[] keyAsBytes = Encoding.UTF8.GetBytes(key);
using (HMACSHA256 hmac = new HMACSHA256(keyAsBytes))
{
// Compute the hash
byte[] hashValue = hmac.ComputeHash(saltedClaimAsBytes);
return Convert.ToBase64String(hashValue);
}