crypt(const char *key, const char *salt) function is one of the C language functions and returns a string encrypted using DES, Blowfish or MD5. This function behaves differently on different operating systems, and some operating systems support more than one algorithm type. At installation time, PHP checks what algorithms are available and what algorithms are used.
This article mainly introduces PHP to use crypt() function for encryption in detail. It has certain reference value. Interested friends can refer to it
1. Code
加密后$str的值为:'.$crypttostr; //输出加密后的变量 ?>
2. Running result
The parameter does not contain salt, The ciphertext obtained by encryption is different every time.
The value of $str before encryption is: apply the crypt() function for one-way encryption!
The value of $str after encryption is: $1$Re4.Gg4.$D.yd00xX0fFfIfp6KrKGN0
3. Code
使用crypt函数进行数据验证
0){ echo "用户登录成功。"; }else{ echo "用户登录失败!"; } }else{ echo "请认真填写用户名和密码!"; } ?> | ||
4. Running results
.
The above is the detailed content of php crypt() encryption function usage example. For more information, please follow other related articles on the PHP Chinese website!