对于密码的处理可以参看 CodeIgniter 文档的安全章节 https://codeigniter.org.cn/user_guide/general/security.html 个人认为这是写的比较好的安全方面的文档.
在密码加密中应该尽量减少使用 md5 方式加密 .
在 Laravel/Lumen 中可以使用 Hash::make() 和 Hash::check() 加解密.
use Illuminate\Support\Facades\Hash;
$pwd = Hash::make($request->input('password')); //加密存储
if (Hash::check('qwe123456', $pwd)) {
// 密码匹配...
}
当然还可以使用 php 自带的加解密方式
$s= password_hash('123456',PASSWORD_BCRYPT); //$2y$10$fjxuIOv1sD3h/pRrqNLuv.th.m2tc/HYg.guhEW5dfRugyPOVYiW2
$hash = '$2y$10$fjxuIOv1sD3h/pRrqNLuv.th.m2tc/HYg.guhEW5dfRugyPOVYiW2';
if (password_verify('123456', $hash)) {
echo 'Password is valid!';
} else {
echo 'Invalid password.';
}