如何在python3中实现crypt选项?在
我理解其用途是:
Hash = crypt.crypt(password, salt)
但是,该函数有一组不同的哈希函数。根据文件:
crypt.METHOD_SHA512 A Modular Crypt Format method with 16 character salt and 86 character hash. This is the strongest method.
crypt.METHOD_SHA256 Another Modular Crypt Format method with 16 character salt and 43 character hash.
crypt.METHOD_MD5 Another Modular Crypt Format method with 8 character salt and 22 character hash.
crypt.METHOD_CRYPT The traditional method with a 2 character salt and 13 characters of hash. This is the weakest method.
同样,我的问题是如何选择函数使用的算法?在
这是一个非常基本的问题,我不能相信我自己没有找到答案-如果我浪费你的时间,我道歉。在
将方法作为salt参数传递。从crypt function docstring:
例如:
在引擎盖下面变成:
^{pr2}$改编自Red Hat solution和@Leonard_Saracini答案(删除反斜杠使其成为一行行):
从2018年8月起,这应该是安全的。在
使用bash:$
python3 -c "import crypt; print(crypt.crypt('password', '\$6\$saltstring'))"
$6$用于SHA512,如果您使用像我这样的bash终端,$必须由\转义
相关问题 更多 >
编程相关推荐