Reputation: 52
I'm setting up a login validation function to compare user entered password against the one stored in db. The db passwords are sha256 then a salt is added to the front and then sha256 again.
This is what I'm currently doing but it does some extra things apparently so I'm not getting just the basic sha256 for example like this website provides https://emn178.github.io/online-tools/sha256.html
from passlib.hash import sha256_crypt
passwordCandidate = "test"
passwordCandidate = sha256_crypt.encrypt(passwordCandidate)
print(passwordCandidate, file=sys.stderr)
What I want to get is:
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
What I'm getting is:
$5$rounds=535000$VZ4p1Kf9FmCL9Czc$.zvnilwPGcHhL54nq13LLrSxi0BXvSl0vW5C0zy5ya/
Upvotes: 1
Views: 589
Reputation: 868
This work with hashlib
import hashlib
passwordCandidate = "test"
print(hashlib.sha256(passwordCandidate.encode()).hexdigest())
# print : 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
Upvotes: 1