Current File : //usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyc
�
�
5Xc@s�dZddlmZddlZddlZeje�Zddlm	Z	ddl
mZddl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_charstclassmethodR
R(((s:/usr/lib/python2.7/site-packages/passlib/handlers/mysql.pyR-s	tmysql41cBsGeZdZdZed�ZejZdZ	e
d��Zd�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(RR((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.pyt<module>s(	1