PHP implements encryption and decryption, and php implements encryption and decryption.
This example describes the encryption and decryption processing class implemented by PHP. We will share this with you for your reference. The details are as follows:
<? Php/* = =================================== copyright agreement: = GPL (The gnu general public license Version 2, June 1991) = ---------------------------------------------------------- = File Name: cls. sys_crypt.php = Abstract: php encryption and decryption processing class = version: 1.0 = reference: passport function of Discuz Forum = ---------------------------------------------------------- = last update date: ===================================================== ==== =======================*/Class SysCrypt {private $ crypt_key; // constructor public function _ construct ($ crypt_key) {$ this-> crypt_key = $ crypt_key;} public function php_encrypt ($ txt) {srand (double) microtime () * 1000000 ); $ encrypt_key = md5 (rand (0,32000); $ ctr = 0; $ tmp = ''; for ($ I = 0; $ I <strlen ($ txt ); $ I ++) {$ ctr = strlen ($ encrypt_key )? 0: $ ctr; $ tmp. = $ encrypt_key [$ ctr]. ($ txt [$ I] ^ $ encrypt_key [$ ctr ++]);} return base64_encode (self ::__ key ($ tmp, $ this-> crypt_key ));} public function php_decrypt ($ txt) {$ txt = self ::__ key (base64_decode ($ txt), $ this-> crypt_key); $ tmp = ''; for ($ I = 0; $ I <strlen ($ txt); $ I ++) {$ md5 = $ txt [$ I]; $ tmp. = $ txt [++ $ I] ^ $ md5;} return $ tmp;} private function _ key ($ txt, $ encrypt_key) {$ encrypt_key = m D5 ($ encrypt_key); $ ctr = 0; $ tmp = ''; for ($ I = 0; $ I <strlen ($ txt); $ I ++) {$ ctr = strlen ($ encrypt_key )? 0: $ ctr; $ tmp. = $ txt [$ I] ^ $ encrypt_key [$ ctr ++];} return $ tmp;} public function _ destruct () {$ this-> crypt_key = null ;}// run the code $ SC = new SysCrypt ('phpwms'); $ text = 'abc000000890000000990099hh '; // print ($ SC-> php_encrypt ($ text); // encrypted print ('<br> '); print ($ SC-> php_decrypt ($ SC-> php_encrypt ($ text); // decrypt?>
If you are interested in encryption and decryption, refer to the online tools on this site:
Online Password Security Detection
High-strength Password generator
MD5 online encryption tool
Thunder, express, and Tornado URL encryption/Decryption tools