PHP implements encryption and decryption processing class, php implements encryption and decryption _ PHP Tutorial

Source: Internet
Author: User
PHP implements encryption and decryption, and php implements encryption and decryption. PHP implements encryption and decryption, and php implements encryption and decryption. this example describes the encryption and decryption processing class implemented by PHP. For your reference, refer to the encryption and decryption processing class implemented by php * PHP and implemented by php.

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; // construct ($ crypt_key) {$ this-> crypt_key = $ crypt_key;} public function php_encrypt ($ txt) {srand (double) microtime () * 1000000); $ encrypt_key = md5 (rand (); $ ctr = 0; $ tmp = ''; for ($ I = 0; $ I
 
  
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 = md5 ($ 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); // encrypt print ('
  
'); 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.