php crypt() encryption function usage example

怪我咯
Release: 2023-03-14 11:42:01
Original
1612 people have browsed it

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; //输出加密后的变量 ?>
Copy after login

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 "请认真填写用户名和密码!"; } ?>
Copy after login

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!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!