小程序解密报错:IV passed is 24 bytes long which is longer than the 16 expected by se

最近在开发项目,黑坑风云榜微信小程序时,需要使用到小程序的开放接口,获取用户手机号码。

原来后台系统里面有 easywechat 3.2 的扩展,调用相关解密函数,结果报错:IV passed is 24 bytes long which is longer than the 16 expected by se。

什么意思呢?

意思是说:给的 sessionKey 是24位的,但解密只需要16位。

如是就多写一行,截取前16位。

$aesKey= substr($aesKey,0,16);

调试了一下,还是不行。

然后去微信小程序官网下载解密的demo. 加上这行,一运行,OK,解密成功。

{"phoneNumber":"17681849100","purePhoneNumber":"17681849100","countryCode":"86","watermark":{"timestamp":1580825334,"appid":"wx2f0dd38d9ca7a188"}}

demo下载查看地址:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html

注: php版本5.6