在yii2中提供了密码加密以及验证的一系列方法,方便我们的使用,它使用的是bcrypt算法。查看源码我们可以发现它使用的是php函数password_hash()和crypt()生成。
/** * $password 要加密的密码 * $hash 加密后的hash字符串 */ $hash = yii::$app->getsecurity()->generatepasswordhash($password);
/** * $password 要验证的明文密码 * $hash 加密后的hash字符串 */ yii::$app->getsecurity()->validatepassword($password, $hash);
如对本文有疑问, 点击进行留言回复!!
[ACTF2020 新生赛]Include 1【文件包含】【读取代码】
算法题解 - 牛客编程巅峰赛S1第6场 - 黄金&钻石&王者组
推荐一个程序员必备网站之一:Dev Hints ,非常实用!
网友评论