微信小程序登录,服务端解密有几率解码失败报errCode=-41003

服务器是将unionId作为唯一id的,需要使用WXBizDataCrypt.decryptData将encryptedData解密出来。不过在调用WXBizDataCrypt.decryptData的时候总是会有几率解密失败,返回errorCode= -41003

服务器端语言:PHP

原因:

每次小程序获取到iv的值中间有空格的,就会出错

js传输 iv 的时候用 encodeURIComponent 函数进行 urlencode (空格其实是符号:+ ?),PHP端接收的时候 urldecode 就可以了

原文地址:https://www.cnblogs.com/blog-dyn/p/14148623.html