DAGDA SEARCH | Back to results | Support

Hashing using SHA256/Salt in Python · GitHub

Source: https://gist.github.com/markito/30a9bc2afbbfd684b31986c2de305d20

Instantly share code, notes, and snippets.

@markito

markito/hashSHASalt.py

Created July 28, 2017 03:18 Show Gist options

Select an option

No results found

Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/markito/30a9bc2afbbfd684b31986c2de305d20.js"></script> Save markito/30a9bc2afbbfd684b31986c2de305d20 to your computer and use it in GitHub Desktop. Download ZIP Hashing using SHA256/Salt in Python Raw hashSHASalt.py 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 Show hidden characters
import uuid
import hashlib
def hashText(text):
"""
Basic hashing function for a text using random unique salt.
"""
salt = uuid.uuid4().hex
return hashlib.sha256(salt.encode() + text.encode()).hexdigest() + ':' + salt
def matchHashedText(hashedText, providedText):
"""
Check for the text in the hashed text
"""
_hashedText, salt = hashedText.split(':')
return _hashedText == hashlib.sha256(salt.encode() + providedText.encode()).hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment