i have a problem parsing a string from a file to passlib.hash.sha512_crypt.encrypt()
My Code is this:
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")
in the file i have this:
password
123456789
987654321
i know that the default rounds for linux password for example is 5000 but in my script, when he try to encrypt the word password with the salt saltsalt he output
$6$saltsalt$YslT1fZBE1gwV0EkEo6UdHwwyL8M/EiBeNfZyr7TZcKxAUd0QkMaP8jmfarPGYVaNUy6haNbxsh6RKsm6dzP81
but when i run it from python shell i got
>>> from passlib.hash import sha512_crypt
>>> sha512_crypt.encrypt("password", salt="saltsalt", rounds=5000)
'$6$saltsalt$qFmFH.bQmmtXzyBY0s9v7Oicd2z4XSIecDzlB5KiA2/jctKu9YterLp8wwnSq.qc.eoxqOmSuNp2xS0ktL3nh/'
Why they doesn't match?