Skip to content

Instantly share code, notes, and snippets.

@amyonsun
Last active July 9, 2021 21:23
Show Gist options
  • Save amyonsun/5490a3ddee1d85c7c44386bae10baac1 to your computer and use it in GitHub Desktop.
Save amyonsun/5490a3ddee1d85c7c44386bae10baac1 to your computer and use it in GitHub Desktop.
Password Hash (sha256) Generator Python Function
# 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