赞
踩
/// <summary>
/// HMAC SHA512签名
/// </summary>
/// <param name="plainStr">明文</param>
/// <param name="key">秘钥</param>
/// <returns>密文</returns>
public static string HMACSHA512Encrypt(string plainStr, string key)
{
string keyToBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(key));
HMACSHA512 hMAC = new HMACSHA512(Encoding.UTF8.GetBytes(keyToBase64));
byte[] hashBytes = hMAC.ComputeHash(Encoding.UTF8.GetBytes(plainStr));
return string.Concat(BitConverter.ToString(hashBytes).Split('-')).ToLower();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。