**一.crypt加密技术** 1.函数声明 ~~~ crypt ( string $str [, string $salt ] ) : string ~~~ 2.代码例子 ~~~ $hash = crypt('123',mt_rand().'-'.time()); ~~~ **二.数据加密和验证实例** // 用户注册 ~~~ $hash = crypt('123',mt_rand().'-'.time()); // 用户登录验证 if(hash_equals($hash, crypt('123', $hash))) { echo 'pass yes'; }else{ echo 'pass no'; } ~~~ **三.官方推荐password\_hash加密技术** #建议用password\_hash来代替crypt技术 #代码实例 ~~~ // 用户注册 $hash=password_hash('123',PASSWORD_DEFAULT); // 用户登录验证 if (password_verify('123', $hash)) { echo 'pass yes'; } else { echo 'pass no'; } ~~~