Php encryption and decryption _ PHP Tutorial

Source: Internet
Author: User
Php encryption and decryption. Encryption and decryption are common tasks. Generally, passwords registered by users are not stored in plain text, so you must add a password first. The simplest of course is to call the md5 function in the Database SQL statement to encrypt and decrypt user passwords. Generally, passwords registered by users are not stored in plain text, so you must add a password first.

The simplest of course is to call the md5 function in the Database SQL statement to encrypt the user password. Here is an encryption/decryption class. If you want to retrieve the original password when the user forgets the password, this class is a useful tool. Of course, this encryption/decryption class can also be used for other purposes.

View source code

Skey = hash ("md5",); safe_b64encode (= ('+', '/', '= '),('-','_', ''), safe_b64decode (= ('-', '_'), ('+', '/'), = () % 4 (. = ('=', (encode ((! = Mcrypt_get_iv_size (Cipher, = mcrypt_create_iv (, = mcrypt_encrypt (Cipher,-> skey, MCRYPT_MODE_ECB, (-> safe_b64encode (decode ((! =-> Safe_b64decode (= mcrypt_get_iv_size (ciphertext, = mcrypt_create_iv (, = mcrypt_decrypt (ciphertext,-> skey, MCRYPT_MODE_ECB ,(}View Code

Bytes. Generally, passwords registered by users are not stored in plain text, so you must add a password first. The simplest of course is to call the md5 function in the Database SQL statement to encrypt user passwords...

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.