• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Cryptography.HMACSHA512类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



HMACSHA512类属于System.Security.Cryptography命名空间,在下文中一共展示了HMACSHA512类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetAlgorithmByFunctionName

 /// <summary>
 /// Every time is created new instance of class to guarantee thread safety
 /// </summary>
 /// <param name="function"></param>
 /// <returns></returns>
 private HMAC GetAlgorithmByFunctionName(string function)
 {
     HMAC a;
     switch(Util.Convertion.EnumNameToValue<HMACFunction>(function))
     {
         case HMACFunction.HMACMD5:
             a = new HMACMD5();
             break;
         case HMACFunction.HMACSHA1:
             a = new HMACSHA1();
             break;
         case HMACFunction.HMACSHA256:
             a = new HMACSHA256();
             break;
         case HMACFunction.HMACSHA384:
             a = new HMACSHA384();
             break;
         case HMACFunction.HMACSHA512:
             a = new HMACSHA512();
             break;
         default:
             throw new ArgumentException("Unknown function", "function");
     }
     return a;
 }
开发者ID:danni95,项目名称:Core,代码行数:30,代码来源:HMACProvider.cs


示例2: 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


示例3: BtceApi

 public BtceApi(string key, string secret, string exchangeHost = null)
 {
     this.key = key;
     hashMaker = new HMACSHA512(Encoding.ASCII.GetBytes(secret));
     nonce = UnixTime.Now;
     this.instanseExchangeHost = exchangeHost ?? ExchangeHost;
 }
开发者ID:GnosisSuperFund,项目名称:BtceApi,代码行数:7,代码来源:BtceApi.cs


示例4: 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


示例5: 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


示例6: Rfc2898DeriveBytes_HMACSHA512

 public Rfc2898DeriveBytes_HMACSHA512(byte[] password, byte[] salt, int iterations)
 {
     Salt = salt;
     IterationCount = iterations;
     _hmacsha512 = new HMACSHA512(password);
     Initialize();
 }
开发者ID:RicardoCampos,项目名称:PKDBF2Examples,代码行数:7,代码来源:Rfc2898DeriveBytes_HMACSHA512.cs


示例7: 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


示例8: 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


示例9: Hash

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


示例10: 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


示例11: BtceApi

 public BtceApi(string key, string secret)
 {
     this.key = key;
     foreach (var b in Encoding.ASCII.GetBytes(secret))
         Console.Write(b);
     hashMaker = new HMACSHA512(Encoding.ASCII.GetBytes(secret));
     nonce = UnixTime.Now;
 }
开发者ID:julien-lebot,项目名称:btce-csharp,代码行数:8,代码来源:BtceApi.cs


示例12: 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


示例13: SetUp

		public override void SetUp () 
		{
			algo = new HMACSHA512 ();
			algo.Key = new byte [8];
			hash = algo;
			// http://blogs.msdn.com/shawnfa/archive/2007/01/31/please-do-not-use-the-net-2-0-hmacsha512-and-hmacsha384-classes.aspx
			legacy = (new HS512 ().BlockSize == 64);
		}
开发者ID:carrie901,项目名称:mono,代码行数:8,代码来源:HMACSHA512Test.cs


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: BtceApi

        public BtceApi(IConfiguration config, ILogger logger)
        {
            _config = config;
            _logger = logger;

            _hashMaker = new HMACSHA512(Encoding.ASCII.GetBytes(_config.SecretKey));

            synchronizeNonce();
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:9,代码来源:BtceApi.cs


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cryptography.HashAlgorithm类代码示例发布时间:2022-05-26
下一篇:
C# Cryptography.HMACSHA256类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap