Created
November 16, 2016 10:31
-
-
Save junquera/7ed86632a2de22478a843b6a23fd4d2b to your computer and use it in GitHub Desktop.
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 time | |
| def genToken(password): | |
| h = hashlib.sha1(password) | |
| h.update(str(int(time.time()*1000))) | |
| return h.hexdigest() | |
| def isValid(password, token): | |
| t = int(time.time()*1000) | |
| for i in range(5000): | |
| h = hashlib.sha1(password) | |
| h.update(str(t - 5000 + i)) | |
| if( h.hexdigest() == token): | |
| return True | |
| return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment