Created
May 3, 2013 20:52
-
-
Save irneh/5514027 to your computer and use it in GitHub Desktop.
This file contains 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
def randstr(length): | |
return ''.join(chr(random.randint(0,255)) for i in range(length)) | |
def hash_password(password, maxtime=0.5, datalength=64): | |
return scrypt.encrypt(randstr(datalength), password, maxtime=maxtime) | |
def verify_password(hashed_password, guessed_password, maxtime=0.5): | |
try: | |
scrypt.decrypt(hashed_password, guessed_password, maxtime) | |
return True | |
except scrypt.error: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment