介绍
这篇文章将为大家详细讲解有关php中的加密解密功能函数有哪些,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
<强>算法一:强>
//加密函数 function lock_url (txt,关键美元=& # 39;www.jb51.net& # 39;) { 时间=美元才能chars “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -=+“;; 美元才能nh =,兰德(0,64); 时间=美元才能ch 识字课(nh)美元美元; 美元才能mdKey =, md5(关键。美元ch); 美元才能mdKey =, substr (mdKey, nh % 8美元,美元nh % 8 + 7); 时间=美元才能txt base64_encode ($ txt); 时间=美元才能tmp & # 39; & # 39;; 我=0;美元才能$ j=0; k 美元;=,0; for 才能;(i=0;美元,美元i用法:
$ str=啊? $ pwd =, lock_url (str); echo “加密之后:“。$ pwd !”& lt; br/在“; echo “解密还原:“.unlock_url ($ pwd);运行结果:
<强>算法二:强>
& lt; php ? function passport_encrypt ($ txt, key 美元;=,& # 39;www.jb51.net& # 39;), {, 将srand才能((双)microtime (), *, 1000000),, 美元才能encrypt_key =, md5(兰德(0,32000)),, 时间=美元才能ctr 0;, 时间=美元才能tmp & # 39; & # 39;,, ,,($小姐:=,0;美元小姐:& lt;, strlen ($ txt);,我+ +美元),{, 时间=美元才能ctr ctr 美元;==,strlen (encrypt_key美元),?,0,:,ctr美元;, 美元才能tmp 。=, encrypt_key美元(ctr)美元。($ txt ($ i), ^, encrypt_key美元[$ ctr + +]),, ,,}, return 才能urlencode (base64_encode (passport_key (tmp美元,,关键))),, }, function passport_decrypt ($ txt, key 美元;=,& # 39;www.jb51.net& # 39;), {, 时间=美元才能txt passport_key (base64_decode (urldecode (txt)美元),,美元键),, 时间=美元才能tmp & # 39; & # 39;,, ,,($小姐:=,0;美元小姐:& lt;, strlen ($ txt);,我+ +美元),{, 时间=美元才能md5 $ txt [$ i];, 美元才能tmp 。=, $ txt (+ + $ i), ^, md5;美元, ,,}, return 才能;tmp;美元, }, function passport_key ($ txt, encrypt_key美元), {, encrypt_key 美元;才能=,md5 (encrypt_key美元),, 时间=美元才能ctr 0;, 时间=美元才能tmp & # 39; & # 39;,, ,,($小姐:=,0;,美元小姐:& lt;, strlen ($ txt);,我+ +美元),{, 时间=美元才能ctr ctr 美元;==,strlen (encrypt_key美元),?,0,:,ctr美元;, 美元才能tmp 。=, txt美元($ i), ^, encrypt_key美元(美元ctr + +),, ,,}, return 才能;tmp;美元, }, 祝辞;用法:
& lt; php ? $ txt =,“1”; 时间=美元key “testkey"; $ encrypt =, passport_encrypt (txt,关键美元); $ decrypt =, passport_decrypt(加密、密钥)美元; echo 加密美元霸主地位;& lt; br>“; echo 解密美元霸主地位;& lt; br>“; ?在php中的加密解密功能函数有哪些