Skip to content

Instantly share code, notes, and snippets.

@mightbesimon
Last active April 3, 2020 14:32
Show Gist options
  • Save mightbesimon/29c8a82467dea6cf9f2a10b80e2440fd to your computer and use it in GitHub Desktop.
Save mightbesimon/29c8a82467dea6cf9f2a10b80e2440fd to your computer and use it in GitHub Desktop.
salt hash
import hashlib
import uuid
def sha256(password):
return hashlib.sha256(password.encode()).hexdigest()
def salt():
return uuid.uuid4().hex
def salted_sha256(password, salt = salt()):
return f'{sha256(salt + password)}:{salt}' if salt is salted_sha256.__defaults__[0] else sha256(salt + password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment