代码改变世界

微信接口生成签名

2020-07-26 09:42  idea555  阅读(560)  评论(0)    收藏  举报

//生成签名
string sourceString = "jsapi_ticket=" + ticket + "&noncestr=" + config.NonceStr + "&timestamp=" + config.Timestamp + "&url=" + url;
//DbHelperSQL.ExecuteSql("insert into test (content) values ('" + sourceString + "')");
byte[] bytes = Encoding.Default.GetBytes(sourceString);
byte[] hashedBytes = System.Security.Cryptography.SHA1.Create().ComputeHash(bytes);
string signature = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();