Пример #1
0
        private string CalculateHmacStringWithTpm(string value)
        {
            byte[] valueByteArray = Encoding.UTF8.GetBytes(value);
            byte[] hmacByteArray  = TpmHelper.CalculateHmac(valueByteArray);

            // converte in stringa il valore calcolato e lo torna
            return(Convert.ToBase64String(hmacByteArray));
        }
Пример #2
0
 private byte[] CypherHmac(byte[] digestBytes, string sharedKey)
 {
     if (enableTpm)
     {
         return(TpmHelper.CalculateHmac(digestBytes));
     }
     else
     {
         var secretKeyBytes = Convert.FromBase64String(sharedKey);
         using (HMACSHA256 hmac = new HMACSHA256(secretKeyBytes))
         {
             return(hmac.ComputeHash(digestBytes));
         }
     }
 }