PHP combined with MD5 implementation of encryption and decryption method, PHP combined with MD5 encryption decryption _php tutorial

Source: Internet
Author: User
Tags php source code

PHP combined with MD5 implementation of encryption and decryption method, PHP combined with MD5 encryption decryption


This paper describes the encryption and decryption method implemented by PHP combined with MD5. Share to everyone for your reference, as follows:

Recently in the collation of the code found a good thing, combined with MD5 encryption and decryption algorithm. On the internet about PHP combined with MD5 encryption, decryption algorithm is less, in fact, PHP manual inside there, change a change on the line. In this post, with this algorithm to load a PHP module MCrypt, or can not be used.

Cryptographic function String2secret ($str) {$key = "123"; $td = Mcrypt_module_open (Mcrypt_des, ' ', ' ECB ', '); $iv = Mcrypt_create_iv (Mcrypt_enc_get_iv_size ($TD), Mcrypt_rand); $ks = Mcrypt_enc_get_key_size ($TD); $key = substr (MD5 ($key), 0, $ks); Mcrypt_generic_init ($TD, $key, $IV); $secret = Mcrypt_generic ($TD, $STR); Mcrypt_generic_deinit ($TD); Mcrypt_module_close ($TD); return $secret;} Decrypt function secret2string ($sec) {$key = "123"; $td = Mcrypt_module_open (Mcrypt_des, ' ', ' ECB ', '); $iv = Mcrypt_create_iv (Mcrypt_enc_get_iv_size ($TD), Mcrypt_rand); $ks = Mcrypt_enc_get_key_size ($TD); $key = substr (MD5 ($key), 0, $ks); Mcrypt_generic_init ($TD, $key, $IV); $string = Mdecrypt_generic ($TD, $sec); Mcrypt_generic_deinit ($TD); Mcrypt_module_close ($TD); Return trim ($string);} Echo secret2string (String2secret ("11111111111111111")); Display result is 11111111111111111echo string2secret ("11111111111111111"); Garbled display

PHP often uses the Add decryption function, Base64_encode,base64_decode.

More about PHP encryption and decryption related content of interested readers can view this site topic: "PHP encryption Method Summary"

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • Analysis of PHP encryption and decryption example
    • SSL encryption decryption, authentication, signature method under PHP (very simple)
    • Detailed PHP encryption decryption string function with source download
    • PHP encapsulated string encryption and decryption function
    • thinkphp Development (Message encryption and decryption)
    • A detailed explanation of PHP cryptographic decryption functions
    • PHP implementation of enhanced encryption decryption class instance
    • PHP source code Analysis of DZX1.5 cryptographic decryption function Authcode usage
    • PHP decrypts Unicode and escape encrypted strings
    • How to use PHP RSA encryption and decryption
    • PHP Encryption Decrypted String summary
    • An example analysis of PHP encryption and decryption class
    • PHP RSA encryption and decryption using the detailed

http://www.bkjia.com/PHPjc/1095688.html www.bkjia.com true http://www.bkjia.com/PHPjc/1095688.html techarticle PHP combined with MD5 implementation of the encryption and decryption method, PHP combined with MD5 encryption and decryption of this article describes the PHP combined with MD5 implementation of the encryption and decryption method. Share to everyone for your reference, as follows: the most ...

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