Home > Article > Backend Development > Encryption using crypt() function-php encryption technology
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!