我有两个PHP页面,其中第1页对字符串onLoad进行加密,加密的字符串将通过URL传递到第2页。
有时(大约8页中有1页)无法解密字符串,并给出以下错误消息:failed to base64 decode the input ...
下面是我所用的:
AES-128-CBCopenssl_random_pseudo_bytes(16);以下是一些附加信息:
有什么建议吗?
发布于 2015-10-14 11:38:40
若要在URL中包含字符串,需要对其进行URL编码。对于基本64,您需要用=替换%3D,但不要这样做。相反,当您在URL中包含字符串时,请使用适当的URL编码函数。
发布于 2015-10-15 12:12:55
感谢“Simba& @David Schwartz”的评论,下面是应该做的事情:
在第1页:
- encrypt the string via openssl_encrypt();
- encode the encrypted string for sending via url by rawurlencode();
- concatenate those "encrypted+encoded" strings and send via url;在第2页:
- take the var out from $_GET;
- decode the var via rawurldecode();
- decrypt the decoded var via openssl_decrypt();现在工作正常~
https://stackoverflow.com/questions/33127515
复制相似问题