Пример #1
0
 protected string ComputeSHA512Hash(string text, string secretKey)
 {
     byte[] _key = Encoding.ASCII.GetBytes(secretKey);
     using (var myhmacsha1 = new HMACSHA1(_key))
     {
         var hashArray = new HMACSHA512(_key).ComputeHash(Encoding.ASCII.GetBytes(text));
         return(hashArray.Aggregate("", (s, e) => s + String.Format("{0:x2}", e), s => s));
     }
 }
Пример #2
0
        private string GetSHAToken(string data, string key)
        {
            // use Encoding.ASCII.GetBytes or Encoding.UTF8.GetBytes

            byte[] _key = Encoding.ASCII.GetBytes(key);
            using (var myhmacsha1 = new HMACSHA1(_key))
            {
                var hashArray = new HMACSHA512(_key).ComputeHash(Encoding.ASCII.GetBytes(data));

                return(hashArray.Aggregate("", (s, e) => s + String.Format("{0:x2}", e), s => s));
            }
        }