diff options
Diffstat (limited to 'passlib/handlers/mysql.py')
-rw-r--r-- | passlib/handlers/mysql.py | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/passlib/handlers/mysql.py b/passlib/handlers/mysql.py index e820744..8f57d05 100644 --- a/passlib/handlers/mysql.py +++ b/passlib/handlers/mysql.py @@ -19,30 +19,29 @@ MySQL 4.1.1 / NEW PASSWORD Description taken from http://dev.mysql.com/doc/refman/6.0/en/password-hashing.html """ -#========================================================= -#imports -#========================================================= -#core +#============================================================================= +# imports +#============================================================================= +# core from hashlib import sha1 import re import logging; log = logging.getLogger(__name__) from warnings import warn -#site -#libs -#pkg +# site +# pkg from passlib.utils import to_native_str from passlib.utils.compat import b, bascii_to_str, bytes, unicode, u, \ byte_elem_value, str_to_uascii import passlib.utils.handlers as uh -#local +# local __all__ = [ 'mysql323', 'mysq41', ] -#========================================================= -#backend -#========================================================= +#============================================================================= +# backend +#============================================================================= class mysql323(uh.StaticHandler): """This class implements the MySQL 3.2.3 password hash, and follows the :ref:`password-hash-api`. @@ -50,16 +49,16 @@ class mysql323(uh.StaticHandler): The :meth:`~passlib.ifc.PasswordHash.encrypt` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords. """ - #========================================================= + #=================================================================== # class attrs - #========================================================= + #=================================================================== name = "mysql323" checksum_size = 16 checksum_chars = uh.HEX_CHARS - #========================================================= + #=================================================================== # methods - #========================================================= + #=================================================================== @classmethod def _norm_hash(cls, hash): return hash.lower() @@ -85,13 +84,13 @@ class mysql323(uh.StaticHandler): add = (add+tmp) & MASK_32 return u("%08x%08x") % (nr1 & MASK_31, nr2 & MASK_31) - #========================================================= + #=================================================================== # eoc - #========================================================= + #=================================================================== -#========================================================= -#handler -#========================================================= +#============================================================================= +# handler +#============================================================================= class mysql41(uh.StaticHandler): """This class implements the MySQL 4.1 password hash, and follows the :ref:`password-hash-api`. @@ -99,17 +98,17 @@ class mysql41(uh.StaticHandler): The :meth:`~passlib.ifc.PasswordHash.encrypt` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords. """ - #========================================================= + #=================================================================== # class attrs - #========================================================= + #=================================================================== name = "mysql41" _hash_prefix = u("*") checksum_chars = uh.HEX_CHARS checksum_size = 40 - #========================================================= + #=================================================================== # methods - #========================================================= + #=================================================================== @classmethod def _norm_hash(cls, hash): return hash.upper() @@ -120,10 +119,10 @@ class mysql41(uh.StaticHandler): secret = secret.encode("utf-8") return str_to_uascii(sha1(sha1(secret).digest()).hexdigest()).upper() - #========================================================= + #=================================================================== # eoc - #========================================================= + #=================================================================== -#========================================================= -#eof -#========================================================= +#============================================================================= +# eof +#============================================================================= |