PHP encryption and decryption functions in detail, encryption and decryption functions in detail _php tutorial

Source: Internet
Author: User

PHP encryption and decryption functions in detail, encryption and decryption functions in detail


Share a PHP cryptographic decryption function that implements the ability to encrypt part of a variable's value.
The encryption code is as follows:

/* Function: Encrypt the string * parameter one: What needs to be encrypted * parameter two: Key */function Passport_encrypt ($STR, $key) {//Cryptographic function Srand ((double) microtime () * 10000   00);   $encrypt _key=md5 (rand (0, 32000));   $ctr = 0;   $tmp = "; for ($i =0; $i
 
  

The decryption code is as follows:

/* Function: Decrypt the String * parameter one: ciphertext to be decrypted * parameter two: Key */function Passport_decrypt ($STR, $key) {//decryption function $str =passport_key (base64_decode   ($STR), $key);   $tmp = "; for ($i =0; $i
   
    

Auxiliary functions:

/* Auxiliary function */function Passport_key ($STR, $encrypt _key) {$encrypt _key=md5 ($encrypt _key);   $ctr = 0;   $tmp = "; for ($i =0; $i
     
      

Use the following as follows:

$str = ' Author: Yu Haomio; tel: 13611972365; e-mail: 123cvbz@163.com ';  $key = ' hacker '; $encrypt =passport_encrypt ($str, $key); $decrypt =passport_decrypt ($encrypt, $key);  Echo ' original: ', $str. '
"; Echo ' ciphertext: ', $encrypt. "
"; echo ' translation: ', $decrypt. '

The above is for everyone to share the PHP encryption and decryption functions, I hope you like, you can apply to their own learning.

http://www.bkjia.com/PHPjc/1065571.html www.bkjia.com true http://www.bkjia.com/PHPjc/1065571.html techarticle PHP encryption and decryption functions in detail, encryption and decryption functions in detail to share a PHP cryptographic decryption function, this function to achieve the value of some variables to encrypt the function. The encryption code is as follows:/* * Function ...

  • 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.