comparison MoinMoin/support/passlib/handlers/digests.py @ 6096:86a41c2bedec

upgrade passlib from 1.6.2 to 1.6.5
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 05 Sep 2016 23:44:04 +0200
parents efd7c0be3339
children 7f0616feeae9
comparison
equal deleted inserted replaced
6095:465cb6f5c6d7 6096:86a41c2bedec
22 "hex_sha256", 22 "hex_sha256",
23 "hex_sha512", 23 "hex_sha512",
24 ] 24 ]
25 25
26 #============================================================================= 26 #=============================================================================
27 # helpers for hexidecimal hashes 27 # helpers for hexadecimal hashes
28 #============================================================================= 28 #=============================================================================
29 class HexDigestHash(uh.StaticHandler): 29 class HexDigestHash(uh.StaticHandler):
30 "this provides a template for supporting passwords stored as plain hexidecimal hashes" 30 """this provides a template for supporting passwords stored as plain hexadecimal hashes"""
31 #=================================================================== 31 #===================================================================
32 # class attrs 32 # class attrs
33 #=================================================================== 33 #===================================================================
34 _hash_func = None # hash function to use - filled in by create_hex_hash() 34 _hash_func = None # hash function to use - filled in by create_hex_hash()
35 checksum_size = None # filled in by create_hex_hash() 35 checksum_size = None # filled in by create_hex_hash()
58 return type(name, (HexDigestHash,), dict( 58 return type(name, (HexDigestHash,), dict(
59 name=name, 59 name=name,
60 __module__=module, # so ABCMeta won't clobber it 60 __module__=module, # so ABCMeta won't clobber it
61 _hash_func=staticmethod(hash), # sometimes it's a function, sometimes not. so wrap it. 61 _hash_func=staticmethod(hash), # sometimes it's a function, sometimes not. so wrap it.
62 checksum_size=h.digest_size*2, 62 checksum_size=h.digest_size*2,
63 __doc__="""This class implements a plain hexidecimal %s hash, and follows the :ref:`password-hash-api`. 63 __doc__="""This class implements a plain hexadecimal %s hash, and follows the :ref:`password-hash-api`.
64 64
65 It supports no optional or contextual keywords. 65 It supports no optional or contextual keywords.
66 """ % (digest_name,) 66 """ % (digest_name,)
67 )) 67 ))
68 68
104 data = render_bytes("%s:%s:%s", user, realm, secret) 104 data = render_bytes("%s:%s:%s", user, realm, secret)
105 return hashlib.md5(data).hexdigest() 105 return hashlib.md5(data).hexdigest()
106 106
107 @classmethod 107 @classmethod
108 def _norm_hash(cls, hash): 108 def _norm_hash(cls, hash):
109 "normalize hash to native string, and validate it" 109 """normalize hash to native string, and validate it"""
110 hash = to_native_str(hash, param="hash") 110 hash = to_native_str(hash, param="hash")
111 if len(hash) != 32: 111 if len(hash) != 32:
112 raise uh.exc.MalformedHashError(cls, "wrong size") 112 raise uh.exc.MalformedHashError(cls, "wrong size")
113 for char in hash: 113 for char in hash:
114 if char not in uh.LC_HEX_CHARS: 114 if char not in uh.LC_HEX_CHARS: