javascript - Decryption of encryptData in applet wx.getUserInfo

WBOY
Release: 2023-03-03 10:44:02
Original
2259 people have browsed it

How to solve this? Can you provide an idea

In the WeChat applet document, the data returned by user login needs to be decrypted. The decryption algorithm is as follows

If the interface involves sensitive data (such as openid in wx.getUserInfo), the plain text content of the interface will not contain sensitive data. If developers need to obtain sensitive data, they need to symmetrically decrypt the encrypted data (encryptData) returned by the interface. The decryption algorithm is as follows:

<code>对称解密使用的算法为 AES-128-CBC,数据采用PKCS#7填充。

对称解密的目标密文为 Base64_Decode(encryptData),

对称解密秘钥 aeskey = Base64_Decode(session_key), aeskey 是16字节

对称解密算法初始向量 iv = aeskey, 同样是16字节</code>
Copy after login
Copy after login

(Documentation link)
https://mp.weixin.qq.com/debu...

Reply content:

How to solve this? Can you provide an idea

In the WeChat applet document, the data returned by user login needs to be decrypted. The decryption algorithm is as follows

If the interface involves sensitive data (such as openid in wx.getUserInfo), the plain text content of the interface will not contain sensitive data. If developers need to obtain sensitive data, they need to symmetrically decrypt the encrypted data (encryptData) returned by the interface. The decryption algorithm is as follows:

<code>对称解密使用的算法为 AES-128-CBC,数据采用PKCS#7填充。

对称解密的目标密文为 Base64_Decode(encryptData),

对称解密秘钥 aeskey = Base64_Decode(session_key), aeskey 是16字节

对称解密算法初始向量 iv = aeskey, 同样是16字节</code>
Copy after login
Copy after login

(Documentation link)
https://mp.weixin.qq.com/debu...

Aren’t there demos in various languages ​​under the document?
https://mp.weixin.qq.com/debu...javascript - Decryption of encryptData in applet wx.getUserInfo
That is, you use the login interface and getUserInfo interface to obtain the information in the applet and then transfer the required fields to the server. The server decrypts according to the document. In fact, this example It’s clearly written in the code

The documentation has examples.

<code>https://mp.weixin.qq.com/debug/wxadoc/dev/demo/aes-sample.zip?t=20161107</code>
Copy after login

It provides cases https://mp.weixin.qq.com/debu...

I was wrong. . Read the documentation carefully next time

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!