时间:2021-07-01 10:21:17 帮助过:17人阅读
加密
- function encode($str,$key)
- {
- $res = base64_encode($str);
- $code = $res^$key;
- return $code;
- }
解密
- function decode($str,$key)
- {
- return base64_decode($str^$key);
- }
完整代码示例:
- $str = '111021';
- $key = 'APPYJJ-PHONE-LAZY';
- function encode($str,$key)
- {
- $res = base64_encode($str);
- $code = $res^$key;
- return $code;
- }
- $str = encode($str,$key);
- print_r($str);
- echo "<hr>";
- function decode($str,$key)
- {
- return base64_decode($str^$key);
- }
- print_r(decode($str,$key));
整个程序很简单~按照逻辑思维来说应该是很难被破解的,在别人不知道你秘钥的情况下;
如果感觉还是不安全的话。那么我就在此抛砖引玉了;建议大家可以继续在加密解密过程中运用移位运算
- //加密的时候;
- $a = $str >> 4;
- //解密的时候则相反
- $a = $str << 4;
ok!~到此为止,博主继续工作了!~~
加密
- function encode($str,$key)
- {
- $res = base64_encode($str);
- $code = $res^$key;
- return $code;
- }
解密
- function decode($str,$key)
- {
- return base64_decode($str^$key);
- }
完整代码示例:
- $str = '111021';
- $key = 'APPYJJ-PHONE-LAZY';
- function encode($str,$key)
- {
- $res = base64_encode($str);
- $code = $res^$key;
- return $code;
- }
- $str = encode($str,$key);
- print_r($str);
- echo "<hr>";
- function decode($str,$key)
- {
- return base64_decode($str^$key);
- }
- print_r(decode($str,$key));
整个程序很简单~按照逻辑思维来说应该是很难被破解的,在别人不知道你秘钥的情况下;
如果感觉还是不安全的话。那么我就在此抛砖引玉了;建议大家可以继续在加密解密过程中运用移位运算
- //加密的时候;
- $a = $str >> 4;
- //解密的时候则相反
- $a = $str << 4;
更多分享一个刚写的PHP加密解密函数相关文章请关注PHP中文网!