Encryption using the Crypt () function-php encryption technology

Source: Internet
Author: User
Tags crypt
The crypt () function can complete one-way encryption functions.

String crypt (String str [, string salt]);

STR: is a string that needs to be encrypted; salt: The interference string used for encryption. If the salt is omitted, a disturbance string is randomly generated.

The crypt () function supports 4 algorithms and lengths:

________________________________________________

Algorithms | Salt length

Crypt_std_des | 2-character (default)

Crypt_ext_des | 9-character

CRYPT_MD5 | 12-character (starting with $1$)

Crypt_blowfish | 16-character (starting with $2$)

———————————————————————————

Crypt () function is one-way encryption, ciphertext can not be reduced to plaintext, the data after each encryption is not the same, how to judge it?

-This is the problem that the salt parameter solves. The crypt () function uses the salt parameter to encrypt the plaintext, and when it is judged, the output information is encrypted again using the same salt parameter, which is compared with the result of two times encryption.

Related Article

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.