Skip to content

Instantly share code, notes, and snippets.

@king6cong
Created March 31, 2017 17:35
Show Gist options
  • Save king6cong/5e5407d66b037c0e00d52f870095bae5 to your computer and use it in GitHub Desktop.
Save king6cong/5e5407d66b037c0e00d52f870095bae5 to your computer and use it in GitHub Desktop.
import hashlib
def hash_passwd(passwd, salt):
return 'sha256$' + hashlib.sha256(passwd + salt).hexdigest()
SALT = "this is a secret and do not share with others"
# use case:
passwd = "this is an example passwd"
passwd_hash = hash_passwd(passwd, SALT)
print(passwd_hash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment