Skip to content

Instantly share code, notes, and snippets.

@junquera
Created November 16, 2016 10:31
Show Gist options
  • Select an option

  • Save junquera/7ed86632a2de22478a843b6a23fd4d2b to your computer and use it in GitHub Desktop.

Select an option

Save junquera/7ed86632a2de22478a843b6a23fd4d2b to your computer and use it in GitHub Desktop.
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