Share a PHP encryption and decryption class, when the user is registered to send mail validation when the estimated use of the code as follows
Code as follows: Class syscrypt{ private $crypt _key= ' http://www.jb51.net ';//key public function __ Construct ($crypt _key) { $this->crypt_key= $crypt _key; } public function Encrypt ($txt) { Srand (Double) microtime () *1000000); $encrypt _key=md5 (rand (0,32000)); $CTR = 0; $tmp = '; for ($i =0 $i <strlen ($txt); $i + +) { $ctr = $ctr ==strlen ($encrypt _key) 0: $ctr; $tmp. =$ encrypt_key[$ctr]. ($txt [$i]^ $encrypt _key[$ctr + +]); } return Base64_encode (Self::__key ($tmp, $this->crypt_key)); &NBSP} public function Decrypt ($txt) { $txt =self::__key (Base64_decode ($txt), $this->crypt_key); $tmp = '; for ($i =0 $i <strlen ($txt); $i + +) { $MD 5= $txt [$i]; $tmp. = $txt [+ + $i]^ $MD 5; } return $tmp; &NBSP} private function __key ($txt, $encrypt _key) { $encrypt _key=md5 ($encrypt _key); $CTR =0; $ Tmp= '; for ($i =0; $i <strlen ($txt);$i + +) { $ctr = $ctr ==strlen ($encrypt _key) 0: $ctr $tmp. = $txt [$i]^ $encrypt _key[$ctr + +]; } return $tmp; &NBSP} public function __destruct () { $this->crypt_key=null; }} How this class is used: code is as follows: $SC =new syscrypt (' http://www.jb51.net '); $text = ' yhm.1234@163.com '; $test 1= $sc->encrypt ($text); Echo ' original: ', $text; echo ' <br/> '; Echo ' ciphertext: ', $test 1; echo "<br/>"; Echo ' Decrypt: ', $sc->decrypt ($test 1); Output similar: Original: yhm.1234@163.com cipher: bs8dbfu6aiocnfflvgzqmgrgbduoylezbxoazgo0bjk= decryption: yhm.1234@163.com