fixed CRYPT
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.00.0 (2012-07-19 16:56:40) dev
|
Version 2.00.0 (2012-07-20 08:58:08) dev
|
||||||
|
|||||||
+2
-1
@@ -1198,7 +1198,8 @@ class Auth(object):
|
|||||||
if URL() == action:
|
if URL() == action:
|
||||||
next = ''
|
next = ''
|
||||||
else:
|
else:
|
||||||
next = '?_next=' + urllib.quote(URL(args=request.args, vars=request.get_vars))
|
next = '?_next=' + urllib.quote(URL(args=request.args,
|
||||||
|
vars=request.get_vars))
|
||||||
|
|
||||||
href = lambda function: '%s/%s%s' % (action, function,
|
href = lambda function: '%s/%s%s' % (action, function,
|
||||||
next if referrer_actions is DEFAULT or function in referrer_actions else '')
|
next if referrer_actions is DEFAULT or function in referrer_actions else '')
|
||||||
|
|||||||
+6
-6
@@ -72,12 +72,12 @@ def get_digest(value):
|
|||||||
raise ValueError("Invalid digest algorithm")
|
raise ValueError("Invalid digest algorithm")
|
||||||
|
|
||||||
DIGEST_ALG_BY_SIZE = {
|
DIGEST_ALG_BY_SIZE = {
|
||||||
128/16: 'md5',
|
128/4: 'md5',
|
||||||
160/16: 'sha1',
|
160/4: 'sha1',
|
||||||
224/16: 'sha224',
|
224/4: 'sha224',
|
||||||
256/16: 'sha256',
|
256/4: 'sha256',
|
||||||
384/16: 'sha384',
|
384/4: 'sha384',
|
||||||
512/16: 'sha512',
|
512/4: 'sha512',
|
||||||
}
|
}
|
||||||
|
|
||||||
def hmac_hash(value, salt, digest_alg='md5'):
|
def hmac_hash(value, salt, digest_alg='md5'):
|
||||||
|
|||||||
+20
-1
@@ -2579,7 +2579,13 @@ class LazyCrypt(object):
|
|||||||
"""
|
"""
|
||||||
compares the current lazy crypted password with a stored password
|
compares the current lazy crypted password with a stored password
|
||||||
"""
|
"""
|
||||||
key = self.crypt.key.split(':')[1] if ':' in self.crypt.key else ''
|
if self.crypt.key:
|
||||||
|
if ':' in self.crypt.key:
|
||||||
|
key = self.crypt.key.split(':')[1]
|
||||||
|
else:
|
||||||
|
key = self.crypt.key
|
||||||
|
else:
|
||||||
|
key = ''
|
||||||
if stored_password.count('$')==2:
|
if stored_password.count('$')==2:
|
||||||
(digest_alg, salt, hash) = stored_password.split('$')
|
(digest_alg, salt, hash) = stored_password.split('$')
|
||||||
masterkey = key+salt
|
masterkey = key+salt
|
||||||
@@ -2629,6 +2635,19 @@ class CRYPT(object):
|
|||||||
Important: hashed password is returned as a LazyCrypt object and computed only if needed.
|
Important: hashed password is returned as a LazyCrypt object and computed only if needed.
|
||||||
The LasyCrypt object also knows how to compare itself with an existing salted password
|
The LasyCrypt object also knows how to compare itself with an existing salted password
|
||||||
|
|
||||||
|
Some tests:
|
||||||
|
|
||||||
|
>>> a = str(CRYPT(digest_alg='sha1',salt=False)('test')[0])
|
||||||
|
>>> a
|
||||||
|
'sha1$$a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
|
||||||
|
>>> CRYPT(digest_alg='sha1',salt=False)('test')[0] == a
|
||||||
|
True
|
||||||
|
>>> CRYPT(digest_alg='sha1',salt=False)('test')[0] == a[6:]
|
||||||
|
True
|
||||||
|
>>> CRYPT(digest_alg='md5',salt=False)('test')[0] == a
|
||||||
|
True
|
||||||
|
>>> CRYPT(digest_alg='md5',salt=False)('test')[0] == a[6:]
|
||||||
|
True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
|||||||
Reference in New Issue
Block a user