Created
July 28, 2017 03:18
-
-
Save markito/30a9bc2afbbfd684b31986c2de305d20 to your computer and use it in GitHub Desktop.
Revisions
-
markito renamed this gist
Jul 28, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
markito created this gist
Jul 28, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ 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()