c# HMACSHA1 加密 返回16进制

匿名 (未验证) 提交于 2019-12-02 23:43:01
        /// <summary>         /// HMACSHA1         /// </summary>         /// <param name="EncryptText"></param>         /// <param name="EncryptKey"></param>         /// <returns></returns>         public static string HMACSHA1Text(string EncryptText, string EncryptKey)         {             //HMACSHA1加密             HMACSHA1 hmacsha1 = new HMACSHA1();             hmacsha1.Key = System.Text.Encoding.UTF8.GetBytes(EncryptKey);              byte[] dataBuffer = System.Text.Encoding.UTF8.GetBytes(EncryptText);             byte[] hashBytes = hmacsha1.ComputeHash(dataBuffer);             String result = BitConverter.ToString(hashBytes);//将运算结果转为string类型             result = result.Replace("-", "").ToUpper();//替换并转为大写             return result;         }

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!