我在将字符串从文件解析到passlib.hash.sha512_crypt.encrypt()时遇到问题
我的代码是这样的:
from passlib.hash import sha512_crypt
h = input("sha512: ")
s = input("salt: ")
d = input("dictionary: ")
dictionary = open(d, "r")
for l in dictionary:
for i in range(1000,7000):
t = sha512_crypt.encrypt( str(l), salt=s, rounds=i)
print (t)
t = t.replace("rounds=" + str(i) + "$", "")
print("[DEBUG] SEARCHING " + str(i) + " USING " + l),
if (t == h):
print("FOUND AT: " + str(i) + "\nCODE IS: " + l)
break
else:
print("NO CODE FOUND")
在文件中我有这个:
password
123456789
987654321
我知道例如 linux 密码的默认轮数是 5000 但在我的脚本中,当他尝试用盐saltsalt加密单词密码时,他输出
$6$saltsalt$YslT1fZBE1gwV0EkEo6UdHwwyL8M/EiBeNfZyr7TZcKxAUd0QkMaP8jmfarPGYVaNUy6haNbxsh6RKsm6dzP81
但是当我从 python shell 运行它时,我得到了
>>> from passlib.hash import sha512_crypt
>>> sha512_crypt.encrypt("password", salt="saltsalt", rounds=5000)
'$6$saltsalt$qFmFH.bQmmtXzyBY0s9v7Oicd2z4XSIecDzlB5KiA2/jctKu9YterLp8wwnSq.qc.eoxqOmSuNp2xS0ktL3nh/'
为什么他们不匹配?