当前位置: 首页>>代码示例>>C#>>正文


C# HMACSHA512.ComputeHash方法代码示例

本文整理汇总了C#中System.Security.Cryptography.HMACSHA512.ComputeHash方法的典型用法代码示例。如果您正苦于以下问题:C# HMACSHA512.ComputeHash方法的具体用法?C# HMACSHA512.ComputeHash怎么用?C# HMACSHA512.ComputeHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Cryptography.HMACSHA512的用法示例。


在下文中一共展示了HMACSHA512.ComputeHash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CryptoSHA512

        public static string CryptoSHA512(string TextToCryptograph)
        {
            var sha512 = new HMACSHA512();
            byte[] passwordArray = System.Text.Encoding.Default.GetBytes(TextToCryptograph);

            return Convert.ToBase64String(sha512.ComputeHash(passwordArray));
        }
开发者ID:rodolpholl,项目名称:bakerymanager,代码行数:7,代码来源:PasswordHelper.cs

示例2: HMACSHA512

 public static byte[] HMACSHA512(byte[] key, byte[] data)
 {
     using (var hmac = new HMACSHA512(key))
     {
         return hmac.ComputeHash(data);
     }
 }
开发者ID:lontivero,项目名称:BitcoinLite,代码行数:7,代码来源:Hashes.cs

示例3: SignFile

 // Computes a keyed hash for a source file and creates a target file with the keyed hash
 // prepended to the contents of the source file.
 public static void SignFile(byte[] key, String sourceFile, String destFile)
 {
     // Initialize the keyed hash object.
     using (HMACSHA512 hmac = new HMACSHA512(key))
     {
         using (FileStream inStream = new FileStream(sourceFile, FileMode.Open))
         {
             using (FileStream outStream = new FileStream(destFile, FileMode.Create))
             {
                 // Compute the hash of the input file.
                 byte[] hashValue = hmac.ComputeHash(inStream);
                 // Reset inStream to the beginning of the file.
                 inStream.Position = 0;
                 // Write the computed hash value to the output file.
                 outStream.Write(hashValue, 0, hashValue.Length);
                 // Copy the contents of the sourceFile to the destFile.
                 int bytesRead;
                 // read 1K at a time
                 byte[] buffer = new byte[1024];
                 do
                 {
                     // Read from the wrapping CryptoStream.
                     bytesRead = inStream.Read(buffer, 0, 1024);
                     outStream.Write(buffer, 0, bytesRead);
                 } while (bytesRead > 0);
             }
         }
     }
 }
开发者ID:michaljaros84,项目名称:OneBigPlayground,代码行数:31,代码来源:HashExample.cs

示例4: JsonWebToken

 static JsonWebToken()
 {
     HashAlgorithms = new Dictionary<JwtHashAlgorithm, Func<byte[], byte[], byte[]>>
                      {
                          {JwtHashAlgorithm.RS256, (key, value) =>
                                                   {
                                                       using (var sha = new HMACSHA256(key))
                                                       {
                                                           return sha.ComputeHash(value);
                                                       }
                                                   }
                          },
                          {JwtHashAlgorithm.HS384, (key, value) =>
                                                   {
                                                       using (var sha = new HMACSHA384(key))
                                                       {
                                                           return sha.ComputeHash(value);
                                                       }
                                                   }
                          },
                          {JwtHashAlgorithm.HS512, (key, value) =>
                                                   {
                                                       using (var sha = new HMACSHA512(key))
                                                       {
                                                           return sha.ComputeHash(value);
                                                       }
                                                   }
                          }
                      };
 }
开发者ID:austinejei,项目名称:sidekick,代码行数:30,代码来源:JsonWebToken.cs

示例5: Hash

 public byte[] Hash(byte[] key, byte[] plainText)
 {
     using (var hmac = new HMACSHA512(key))
     {
         return hmac.ComputeHash(plainText);
     }
 }
开发者ID:Lsuwito,项目名称:SampleApp,代码行数:7,代码来源:HmacSha512HashAlgorithm.cs

示例6: Encode

        public static string Encode(string publicKey, int choice = 2)
        {
            byte[] hashMessage = null;
            byte[] messageBytes = m_encoding.GetBytes(publicKey);

            switch (choice%6)
            {
                case 0:
                    var hmacmd5 = new HMACMD5(m_keyBytes);
                    hashMessage = hmacmd5.ComputeHash(messageBytes);
                    break;
                case 1:
                    var hmacripedmd160 = new HMACRIPEMD160(m_keyBytes);
                    hashMessage = hmacripedmd160.ComputeHash(messageBytes);
                    break;
                case 2:
                    var hmacsha1 = new HMACSHA1(m_keyBytes);
                    hashMessage = hmacsha1.ComputeHash(messageBytes);
                    break;
                case 3:
                    var hmacsha256 = new HMACSHA256(m_keyBytes);
                    hashMessage = hmacsha256.ComputeHash(messageBytes);
                    break;
                case 4:
                    var hmacsha384 = new HMACSHA384(m_keyBytes);
                    hashMessage = hmacsha384.ComputeHash(messageBytes);
                    break;
                case 5:
                    var hmacsha512 = new HMACSHA512(m_keyBytes);
                    hashMessage = hmacsha512.ComputeHash(messageBytes);
                    break;
            }

            return Convert.ToBase64String(hashMessage);
        }
开发者ID:nexaddo,项目名称:HMACencryption,代码行数:35,代码来源:Authentication.cs

示例7: ComputeSHA

        public static string ComputeSHA(string str, string key)
        {
            byte[] passwordBytes = ASCIIEncoding.ASCII.GetBytes(str);
            byte[] saltBytes = ASCIIEncoding.ASCII.GetBytes(key);
            var crypt = new HMACSHA512(saltBytes);

            return BitConverter.ToString(crypt.ComputeHash(passwordBytes)).Replace("-", "");
        }
开发者ID:Lokimora,项目名称:TimeManager,代码行数:8,代码来源:HashGenerator.cs

示例8: HashingAMessageWithASecretKey

 public byte[] HashingAMessageWithASecretKey(byte[] iterationNumberByte, byte[] userIdByte)
 {
     using (var hmac = new HMACSHA512(userIdByte))
     {
         byte[] hash = hmac.ComputeHash(iterationNumberByte);
         return hash;
     }
 }
开发者ID:jobairkhan,项目名称:TimeBasedOneTimePassword,代码行数:8,代码来源:HashSha512.cs

示例9: getHash

 private static byte[] getHash(byte[] keyByte, byte[] messageBytes)
 {
     using (var hmacsha512 = new HMACSHA512(keyByte))
     {
         Byte[] result = hmacsha512.ComputeHash(messageBytes);
         return result;
     }
 }
开发者ID:Horndev,项目名称:Bitcoin-Exchange-APIs.NET,代码行数:8,代码来源:KrakenCrypto.cs

示例10: GenerateSHA512Signature

        public string GenerateSHA512Signature(FormUrlEncodedContent request)
        {
            HMAC digester = new HMACSHA512(this.PrivateKeyBytes);
            StringBuilder hex = new StringBuilder();
            byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(request.ReadAsStringAsync().Result);

            return BitConverter.ToString(digester.ComputeHash(requestBytes)).Replace("-", "").ToLower();
        }
开发者ID:dxzcc,项目名称:ncrypto-currency-exchange,代码行数:8,代码来源:AbstractSha512Exchange.cs

示例11: Generate

        public string Generate(string password)
        {
            byte[] msgByte = ASCIIEncoding.ASCII.GetBytes(password);

            HMACSHA512 hmac = new HMACSHA512();
            byte[] hashMsg = hmac.ComputeHash(msgByte);

            return HttpServerUtility.UrlTokenEncode(hashMsg);
        }
开发者ID:Nimrodda,项目名称:TravelersAround,代码行数:9,代码来源:HMACSHA512APIKeyGenerator.cs

示例12: ComputeMacSha512

        /// <summary>
        /// Computes the mac sha512.
        /// </summary>
        /// <param name="storageKey">The storage key.</param>
        /// <param name="canonicalizedString">The canonicalized string.</param>
        /// <returns>The computed hash.</returns>
        internal static string ComputeMacSha512(StorageKey storageKey, string canonicalizedString)
        {
            byte[] dataToMAC = Encoding.UTF8.GetBytes(canonicalizedString);

            using (HMACSHA512 hmacsha1 = new HMACSHA512(storageKey.Key))
            {
                return System.Convert.ToBase64String(hmacsha1.ComputeHash(dataToMAC));
            }
        }
开发者ID:nagyist,项目名称:azure-sdk-for-mono,代码行数:15,代码来源:StorageKey.cs

示例13: Hash

 public byte[] Hash(byte[] clearBytes)
 {
     using (var hmac = new HMACSHA512(_key))
     {
         hmac.Initialize();
         byte[] hashBytes = hmac.ComputeHash(clearBytes);
         return hashBytes;
     }
 }
开发者ID:daffers,项目名称:Magnum,代码行数:9,代码来源:Sha512HMacHashingService.cs

示例14: Sign

        public static String Sign(HttpRequestMessage request, String secretKey)
        {
            String message = BuildMessage(request);

            HMACSHA512 hmac = new HMACSHA512(Convert.FromBase64String(secretKey));
            byte[] signature = hmac.ComputeHash(encoding.GetBytes(message));

            return Convert.ToBase64String(signature);
        }
开发者ID:nazhir,项目名称:kawaldesa,代码行数:9,代码来源:CryptographyHelper.cs

示例15: SignString512

 public static string SignString512(string stringToSign, string secretKey)
 {
     byte[] secretkeyBytes = Convert.FromBase64String(secretKey);
     byte[] inputBytes = Encoding.UTF8.GetBytes(stringToSign);
     using (var hmac = new HMACSHA512(secretkeyBytes))
     {
         byte[] hashValue = hmac.ComputeHash(inputBytes);
         return System.Convert.ToBase64String(hashValue);
     }
 }
开发者ID:cornerstoneondemand,项目名称:CSOD-Sample-Service-Call-POST,代码行数:10,代码来源:Program.cs


注:本文中的System.Security.Cryptography.HMACSHA512.ComputeHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。