Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微信签名算法需过滤空值 #7

Closed
shushenghong opened this issue Oct 8, 2019 · 2 comments
Closed

微信签名算法需过滤空值 #7

shushenghong opened this issue Oct 8, 2019 · 2 comments

Comments

@shushenghong
Copy link

image
参考文档:
微信签名算法

签名生成的通用步骤如下:

第一步,设所有发送或者接收到的数据为集合M,将集合M内非空参数值的参数按照参数名ASCII码从小到大排序(字典序),使用URL键值对的格式(即key1=value1&key2=value2…)拼接成字符串stringA。

特别注意以下重要规则:

◆ 参数名ASCII码从小到大排序(字典序);
◆ 如果参数的值为空不参与签名;
◆ 参数名区分大小写;
◆ 验证调用返回或微信主动通知签名时,传送的sign参数不参与签名,将生成的签名与该sign值作校验。
◆ 微信接口可能增加字段,验证签名时必须支持增加的扩展字段
第二步,在stringA最后拼接上key得到stringSignTemp字符串,并对stringSignTemp进行MD5运算,再将得到的字符串所有字符转换为大写,得到sign值signValue。
@iGoogle-ink
Copy link
Member

iGoogle-ink commented Oct 26, 2019

谢谢了,确实需要对value值判空,有可能是空字符串

@Rbcum
Copy link

Rbcum commented Dec 12, 2019

在调用微信接口返回,如果有些int类型的节点值为0,那么在VerifyWeChatSign时这些节点会丢失,导致验签失败,这个怎么解决好点?把int节点换成*int怎样?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants