- 当前 Bug 的表现(可附上截图)
- 调用第三方服务商 登录接口
https://qyapi.weixin.qq.com/cgi-bin/service/miniprogram/jscode2session?suite_access_token=SUITE_ACCESS_TOKEN&js_code=CODE&grant_type=authorization_code
返回
{"corpid":"xx","userid":"xx","session_key":"VWVHgIpiHewNxDYQuStaew==","errcode":0,"errmsg":"ok"}
2.调用微信运动服务API
wx.getWeRunData
返回
{errMsg: "getWeRunData:ok", encryptedData: "XCDaUmN15a6+uiam/sHqPiqizpbdGcyWjlgRxo888NoUCviPCE…L47QAqhmtUUKlLeVOFn4hjjg71Aq3nimQkEod8MttOirEN8HE", iv: "Zi6zI9lcG5GAhrSqz4w0BQ=="}
3.调用解密
var pc = new WXBizDataCrypt(appid, sessionKey)
console.log(pc)
var data = pc.decryptData(encryptedData, iv)
返回
"���
������=�϶y܁H�}E]��씋�2�ds/m���5�ښ��
%&��)_������2!��|=[7�8&sC1<����c�/�eN^^��
Ӫ &,`��z
�Kwk�|���q�+�_r9\ֽ�\?�(K������"w��AWD�{[6Az��)Ћ�����j�����l�b�ߠ��Ɓ9^M�f]�R[�1wR��.M(e�<��xL�(�0mـ3�?��&_O�
S��n�q쫺g��zʱ�qo���U�c�����k%�Y�-Ԧ�>z���V��
�����k�
�B[���"Ĉ�kQ�ӹ�����&�����fR�U���~~��"&�}"�w;{�@
�֒VG��ģ��������!���,Q�Y
��ED
�LR^m�q֚����i�._BR�/���~+�}e�$� �۵%F�m’(�Bᡖ�;��/P�
����[��,�(�<8�5���m6�ۤ�#�3lJ����<�oi��Ǎ��d"�� �$ƪIѿ�e���Ȗ��g/4��G��Z*�"�’O�Ak�|K���y��6��!��@����(lȾ��خ����}�֊]`ׂ�~n�V
�+��[:�#��W��������J�P3�F0�f��N���:jі��m�������6�)��=$�9*�o�\��nM
��BO�L��?X{�C���~�ϩ�H?l[V�����+�9j����w�x’!r4:+hb����7�hnp
2���ڸ��6x-4��^C�V�!/�p�Q)#xkb����0v���V���y�R��1?�Zc���[��u����HAO�’ӷ®I%0��%�}>O��;�+���Ej2�h�w���s�`m�I���H�8�t���Q�P��3�4�L�8vo.�� 4:ؒ�6�el��F�� �?h�p�z�Xɉ’w���~c
ʹ����}��R<`�0t�B�Ѯ���
�E����������’jYEG�B�G ��r����Yfq�sCnY����
3q��Y�^{ɍ��a��@M����wݨz�z<o�������qq��1��z�]h��C��Jqs��e&��-�غ��-�ۚ���li�����
g��b�9Ο{���}T!/T�J�J}t�*ٰ�)�GT���˜.��N��PIa��U�.�J��c���|�o�o�
c���$���V�A�o�S��� "
解密方法如下:
var crypto = require(‘crypto’);
var Buffer = require(‘safe-buffer’).Buffer;
function WXBizDataCrypt (appId, sessionKey) {
this.appId = appId
this.sessionKey = sessionKey
}
WXBizDataCrypt.prototype.decryptData = function (encryptedData, iv) {
debugger
// base64 decode
var sessionKey = Buffer.from(this.sessionKey, ‘base64’)
encryptedData = Buffer.from(encryptedData, ‘base64’)
iv = Buffer.from(iv, ‘base64’)
try {
// 解密
var decipher = crypto.createDecipheriv(‘aes-128-cbc’, sessionKey, iv)
// 设置自动 padding 为 true,删除填充补位
decipher.setAutoPadding(true)
var decoded = decipher.update(encryptedData, ‘binary’, ‘utf8’)
decoded += decipher.final(‘utf8’)
/*decoded = JSON.parse(decoded)*/
} catch (err) {
/*throw new Error(‘Illegal Buffer’)*/
}
/*if (decoded.watermark.appid !== this.appId) {
throw new Error(‘Illegal Buffer’)
}*/
return decoded
}
module.exports = WXBizDataCrypt
使用微信小程序登录调用正常
文档问题:企业微信APi文档里面说支持,小程序里面说不支持
__
__
文档也有问题 企业微信现在是否支持微信运动 ?