Current File : //usr/lib/python2.7/site-packages/passlib/handlers/digests.pyo
�
�
5Xc@s&dZddlZddlZeje�ZddlmZmZm	Z	m
Z
ddlmZm
Z
ddljjZddlmZdddd	d
dgZdejfd
��YZed�Zed�Zed�Zde_ed�Zed�Zed�Zdejfd��YZdS(s.passlib.handlers.digests - plain hash digests
i����N(t
to_native_strtto_bytestrender_bytestconsteq(tunicodet
str_to_uascii(tlookup_hashtcreate_hex_hashthex_md4thex_md5thex_sha1t
hex_sha256t
hex_sha512t
HexDigestHashcBs;eZdZdZdZejZe	d��Z
d�ZRS(sTthis provides a template for supporting passwords stored as plain hexadecimal hashescCs
|j�S(N(tlower(tclsthash((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyt
_norm_hash(scCs:t|t�r!|jd�}nt|j|�j��S(Nsutf-8(t
isinstanceRtencodeRt
_hash_funct	hexdigest(tselftsecret((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyt_calc_checksum,sN(t__name__t
__module__t__doc__tNoneRt
checksum_sizetuht	HEX_CHARStchecksum_charstclassmethodRR(((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyR
s	cCsgt|�}d|j}t|tftd|d|dt|j�d|jddd|jf��S(	Nthex_tnameRRRiRs�This class implements a plain hexadecimal %s hash, and follows the :ref:`password-hash-api`.

It supports no optional or contextual keywords.
(RR#ttypeR
tdicttstaticmethodtconsttdigest_size(tdigesttmoduletinfoR#((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyR5s

tmd4tmd5tunsalted_md5tsha1tsha256tsha512thtdigestcBs�eZdZdZdZdZdZedd��Z	ed��Z
edd��Zed	��Ze
jd
ddd
�ed���Ze
jd
ddd
�edd���ZRS(sFhtdigest hash function.

    .. todo::
        document this hash
    R2tusertrealmtencodingsutf-8cCs�|s|j}ntj|�t|t�r@|j|�}nt||d�}t||d�}td|||�}tj	|�j
�S(NR3R4s%s:%s:%s(tdefault_encodingRtvalidate_secretRRRRRthashlibR-R(RRR3R4R5tdata((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyR\s
cCsxt|dd�}t|�dkr<tjj|d��nx5|D]-}|tjkrCtjj|d��qCqCW|S(s0normalize hash to native string, and validate ittparamRi s
wrong sizesinvalid chars in hash(RtlenRtexctMalformedHashErrortLC_HEX_CHARS(RRtchar((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyRjs
cCs4|j|�}|j||||�}t||�S(N(RRR(RRRR3R4R5tother((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pytverifyuscCs*y|j|�Wntk
r%tSXtS(N(Rt
ValueErrortFalsetTrue(RR((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pytidentify{s

t
deprecateds1.7tremoveds2.0cCs|jddd�S(Nt(R(R((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyt	genconfig�scCs#|j|�|j||||�S(N(RR(RRtconfigR3R4R5((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pytgenhash�s
((susersrealmsencodingN(RRRR#tsetting_kwdstcontext_kwdsR6R!RRRRARERtdeprecated_methodRIRK(((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyR2Qs 
( RR8tloggingt	getLoggerRtlogt
passlib.utilsRRRRtpasslib.utils.compatRRtpasslib.utils.handlerstutilsthandlersRtpasslib.crypto.digestRt__all__t
StaticHandlerR
RRR	tdjango_nameR
RRtMinimalHandlerR2(((s</usr/lib/python2.7/site-packages/passlib/handlers/digests.pyt<module>s,"