public static byte[] sha256sum(byte[] key, byte[] message) { IMacAlgorithmProvider provider = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithm.HmacSha256); ICryptographicKey hmacKey = provider.CreateKey(key); byte [] hmac = CryptographicEngine.Sign(hmacKey, message); return(hmac); }
public static bool Verify(byte[] key, byte[] message, byte[] signature) { IMacAlgorithmProvider provider = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithm.HmacSha256); ICryptographicKey hmacKey = provider.CreateKey(key); return(CryptographicEngine.VerifySignature(hmacKey, message, signature)); }