fixed a potential timing attack, thanks Kirill Spitsin

This commit is contained in:
Massimo Di Pierro
2012-06-13 16:45:30 -05:00
parent 4a06f92c32
commit 01a2981ed4
3 changed files with 8 additions and 3 deletions
+4
View File
@@ -19,6 +19,10 @@ import logging
logger = logging.getLogger("web2py")
def compare(a,b):
""" compares two strings and not vulnerable to timing attacks """
return len(a)==len(b) and all(x==b[i] for i,x in enumerate(a))
def md5_hash(text):
""" Generate a md5 hash with the given text """
return hashlib.md5(text).hexdigest()