Encryption using crypt() function-php encryption technology

PHPz
Release: 2023-03-07 09:00:02
Original
2251 people have browsed it

The crypt() function can complete the one-way encryption function.

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

//str: is the string that needs to be encrypted; salt: is The interference string used when encrypting. If salt is omitted, an interference string will be randomly generated.

The crypt() function supports 4 algorithms and lengths:

______________________________________________

##                                                                                                                 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, and the ciphertext cannot be restored The encrypted data is not the same every time. How to judge?

——This is the problem that the salt parameter is to solve. The crypt() function uses the salt parameter to encrypt the plain text. When judging, the output information is encrypted again using the same salt parameter, and the judgment is made by comparing the results after the two encryptions.

The above is the detailed content of Encryption using crypt() function-php encryption technology. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template