## 我的报错场景 >在【微信小程序】开发中 <font color="red">加密数据解密算法</font> 报错,后来经过排查发现是由于<font color="blue">session_key('1744eFm+jcmxMOKxMw=='</font>)中存在特殊符号<font color="bule">'+'</font>,后端接收到的参数为<font color="blue">'1744eFm jcmxMOKxMw=='</font>,前后不一致,导致解密报错  ## 解决办法 >前端使用<font color="bule">encodeURIComponent(key)</font>对key进行编码,后端<font color="bule">decodeURIComponent(key)</font>,这样就能拿到完整的数据 ## 顺便说一下encodeURI与encodeURIComponent的区别 > <font color="bule">encodeURI</font> 该方法的目的是对 URI 进行完整的编码,因此对以下在 URI 中具有特殊含义的 ASCII 标点符号,encodeURI() 函数是不会进行转义的:;/?:@&=+$,# > ><font color="bule"> encodeURIComponent </font> “; / ? : @ & = + $ , #”,这些在encodeURI()中不被编码的符号,在encodeURIComponent()中统统会被编码。至于具体的编码方法,两者是一样。