MD5签名算法
private string CalMd5(string str){
var md5 = MD5.Create();var bs = md5.ComputeHash(Encoding.UTF8.GetBytes(str));var sb = new StringBuilder();foreach (byte b in bs){
sb.Append(b.ToString("x2"));}return sb.ToString().ToUpper();}
HMAC-SHA256签名算法
private string CalcHMACSHA256Hash(string plaintext, string salt){
string result = "";var enc = Encoding.Default;byte[]baText2BeHashed = enc.GetBytes(plaintext),baSalt = enc.GetBytes(salt);System.Security.Cryptography.HMACSHA256 hasher = new HMACSHA256(baSalt);byte[] baHashedText = hasher.ComputeHash(baText2BeHashed);result = string.Join("", baHashedText.ToList().Select(b => b.ToString("x2")).ToArray());return result;}