微信登录密码错误,现在无法登陆微信
微信公众号支付 HMACSHA256加密错误?支付签名一直错误,按照签名步骤校验:第一步 k = v 正确对照,第二步链接商户key也是对的,到第三步生成sign ( HMACSHA256加密)与校验签名工具得出的sign 不对照,不知道哪里出了问题,使用了很多种HMACSHA256加密代码: public static string GetHash(string message, string secret) { //第一种 secret = secret ?? ""; byte[] keyByte = Encoding.GetEncoding("UTF-8").GetBytes(secret); byte[] messageBytes = Encoding.GetEncoding("UTF-8").GetBytes(message); using (var hmacsha256 = new HMACSHA256(keyByte)) { byte[] hashmessage = hmacsha256.ComputeHash(messageBytes); string result = BitConverter.ToString(hashmessage); result = result.Replace("-", ""); return result.ToUpper(); } //第二种 //byte[] clearBytes = Encoding.UTF8.GetBytes(message); //byte[] keyByte = Encoding.UTF8.GetBytes(secret); //SHA256 sha256 = new SHA256Managed(); //sha256.ComputeHash(clearBytes); //byte[] hashedBytes = sha256.Hash; //sha256.Clear(); //string output = BitConverter.ToString(hashedBytes).Replace("-", ""); //return output.ToUpper(); //第三种 //string result = ""; //var enc = Encoding.Default; //byte[] //baText2BHashed = enc.GetBytes(message), //baSalt = enc.GetBytes(secret); //System.Security.Cryptography.HMACSHA256 hasher = new HMACSHA256(baSalt); //byte[] baHashedText = hasher.ComputeHash(baText2BHashed); //result = string.Join("", baHashedText.ToList().Select(b => b.ToString("x2")).ToArray()); //return result.ToUpper(); } 求各位大神看看,有什么不对的帮我解答一下。
2021-05-02