ó ö 5Xc@sÙdZddlmZddlZddlZejeƒZddlm Z ddl m Z ddl m Z mZmZmZmZddljjZddgZdejfd „ƒYZd ejfd „ƒYZdS( s8passlib.handlers.mysql MySQL 3.2.3 / OLD_PASSWORD() This implements Mysql's OLD_PASSWORD algorithm, introduced in version 3.2.3, deprecated in version 4.1. See :mod:`passlib.handlers.mysql_41` for the new algorithm was put in place in version 4.1 This algorithm is known to be very insecure, and should only be used to verify existing password hashes. http://djangosnippets.org/snippets/1508/ MySQL 4.1.1 / NEW PASSWORD This implements Mysql new PASSWORD algorithm, introduced in version 4.1. This function is unsalted, and therefore not very secure against rainbow attacks. It should only be used when dealing with mysql passwords, for all other purposes, you should use a salted hash function. Description taken from http://dev.mysql.com/doc/refman/6.0/en/password-hashing.html i˙˙˙˙(tsha1N(twarn(t to_native_str(t bascii_to_strtunicodetutbyte_elem_valuet str_to_uasciitmysql323tmysq41cBs;eZdZdZdZejZed„ƒZ d„Z RS(sThis class implements the MySQL 3.2.3 password hash, and follows the :ref:`password-hash-api`. It has no salt and a single fixed round. The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords. RicCs |jƒS(N(tlower(tclsthash((s:/usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyt _norm_hash>sc CsÖt|tƒr!|jdƒ}nd}d}d}d}d}d}xr|D]j}||krdqLnt|ƒ} ||d@|| |d >|@N}||d >|A|@}|| |@}qLWtd ƒ||@||@fS( Nsutf-8I˙˙˙˙i˙˙˙s i5W0PiqV4ii?is%08x%08x(t isinstanceRtencodeRR( tselftsecrettMASK_32tMASK_31tWHITEtnr1tnr2taddtcttmp((s:/usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyt_calc_checksumBs    "( t__name__t __module__t__doc__tnamet checksum_sizetuht HEX_CHARStchecksum_charst classmethodR R(((s:/usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyR-s  tmysql41cBsGeZdZdZedƒZejZdZ e d„ƒZ d„Z RS(sThis class implements the MySQL 4.1 password hash, and follows the :ref:`password-hash-api`. It has no salt and a single fixed round. The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords. R$t*i(cCs |jƒS(N(tupper(R R ((s:/usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyR pscCsIt|tƒr!|jdƒ}nttt|ƒjƒƒjƒƒjƒS(Nsutf-8(RRRRRtdigestt hexdigestR&(RR((s:/usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyRts( RRRRRt _hash_prefixR R!R"RR#R R(((s:/usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyR$^s  (RthashlibRtretloggingt getLoggerRtlogtwarningsRt passlib.utilsRtpasslib.utils.compatRRRRRtpasslib.utils.handlerstutilsthandlersR t__all__t StaticHandlerRR$(((s:/usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyts  ( 1