using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Text; namespace AlibabaSDK.Setting { public class AlibabaPlatHelper { /// /// 验签,防篡改 /// /// /// /// public static bool MsgCheckSign(string message, string aop_signature) { string tmp = $"message{message}"; byte[] signatureKey = Encoding.UTF8.GetBytes(AlibabaApiSet.SignKey); HMACSHA1 hmacsha1 = new HMACSHA1(signatureKey); byte[] hashBytes = hmacsha1.ComputeHash(Encoding.UTF8.GetBytes(tmp)); byte[] hash = hmacsha1.Hash; //TO HEX string sign = BitConverter.ToString(hashBytes).Replace("-", "").ToUpper(); return sign == aop_signature; } } }