Moodle将哈希密码保存在用户表中,格式如下:
If the stored password is:
$2y$10$UB6vKrpw227eqVXj2PiPou9c0eRtxsdU02fo9.wc3VtsA2FI.gS6a
then:$2y$
= the id of the hashing algorithm used (crypt_blowfish), enclosed in dollar signs.10$
= the cost of using that algorithm (two digits) followed by a dollar sign.UB6vKrpw227eqVXj2PiPou
= randomly generated secure salt (22 characters).9c0eRtxsdU02fo9.wc3VtsA2FI.gS6a
= the hash (31 characters).
我有明文密码。我不知道如何用Python检查它。在
只需使用
那么只需调用
^{pr2}$checkpw()
函数:请注意,bcrypt使用的是字节而不是字符串,这就是为什么用户输入必须通过
.encode()
运行。在相关问题 更多 >
编程相关推荐