c# HMACSHA1 加密 返回16进制

        /// 
        /// HMACSHA1
        /// 
        /// 
        /// 
        /// 
        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;
        }

 

转载于:https://www.cnblogs.com/wangxlei/p/11024039.html

你可能感兴趣的:(c# HMACSHA1 加密 返回16进制)