Improvements on PHP token Token

不言
Release: 2023-04-01 16:06:01
Original
1857 people have browsed it

这篇文章主要介绍了关于PHP令牌Token的改进,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

那个版本中,存在一个小问题,因为要做可逆加密,而加密出来的字符是不可显示字符+乱码,所以我用了 base64对其进行了处理,这样一来,就不会有乱码和不可显示字符了。

正是由于使用了 base64 ,所以在把这个令牌通过 GET方法发送的时候,出现了问题。
比如:http://test/test.php?a=1+2
你用 $_GET["a"] 取得是:1 2 ,即那个加号没有了。一开始我用 urlencode 对其进行转换,但是总有那么一两的结果是意料外的。
后来想想 base64 的字符就限定于: [A-Za-z0-9\+\/=] 这么多,加号出问题,我就把加号换成不出问题的符号,下划线是最好的选择。下面是修改后的代码:
GEncrypt.inc.php

Copy after login

GToken.inc.php

Copy after login

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!

相关推荐:

如何利用PHP解决网站大流量与高并发的问题

The above is the detailed content of Improvements on PHP token Token. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!