Encryption and decryption module in PHP-mcrypt

Source: Internet
Author: User
Tags mcrypt

<?PHP/*turn on encryption algorithms and patterns*/    $TD= Mcrypt_module_open (' rijndael-256 ', ' ', ' ofb ', '); /*creates an initial vector and detects the key length. * Windows platform please use Mcrypt_rand. */    $iv= Mcrypt_create_iv (Mcrypt_enc_get_iv_size ($TD),mcrypt_dev_random); $ks= Mcrypt_enc_get_key_size ($TD); /*Create key*/    $key=substr(MD5(' Very secret key '), 0,$ks); /*Initializing Encryption*/Mcrypt_generic_init ($TD,$key,$iv); /*Encrypt Data*/    $encrypted= Mcrypt_generic ($TD, ' This is very important data '); /*end encryption, perform cleanup work*/Mcrypt_generic_deinit ($TD); /*initial dissolve secret module*/Mcrypt_generic_init ("T",$key,$iv); /*Decrypt Data*/    $decrypted= Mdecrypt_generic ($TD,$encrypted); /*end decryption, perform cleanup work, and close the module*/Mcrypt_generic_deinit ($TD); Mcrypt_module_close ($TD); /*display text*/    Echo Trim($decrypted) . "\ n";?>

Encryption and decryption module in PHP-mcrypt

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.