Last active
April 3, 2020 14:32
-
-
Save mightbesimon/29c8a82467dea6cf9f2a10b80e2440fd to your computer and use it in GitHub Desktop.
salt hash
This file contains hidden or 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 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