Last active
July 9, 2021 21:23
-
-
Save amyonsun/5490a3ddee1d85c7c44386bae10baac1 to your computer and use it in GitHub Desktop.
Password Hash (sha256) Generator Python Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import from library | |
from hashlib import sha256 | |
# same for all users | |
public_extra = 'Some random string' | |
# function | |
def password_hash_generator(password, private_extra): | |
# private_extra is different for every user | |
hash_of_password = sha256((password + private_extra + public_extra).encode('utf-8')).hexdigest() | |
return hash_of_password | |
# generate has using function | |
hash = password_hash_generator('MyPassword', 'some extra characters') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment