Current File : //proc/3/task/3/cwd/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyc
�
b-�Qc@sfdZdZdZddlZddlZdd�Zd�Zd�Zd �Zd
�Z d�Z
d�Zee e
egZd
dddgZ
ddd��YZdZdZdZdd�ZedkrbdZde�j�ks�t�dee�j�kst�deed�j�ks.t�ee�Zeje�dej�ksbt�ndS(s�A sample implementation of SHA-1 in pure Python.
Framework adapted from Dinu Gherman's MD5 implementation by
J. Hallén and L. Creighton. SHA-1 implementation based directly on
the text of the NIST standard FIPS PUB 180-1.
s
2004-11-17g��Q��?i����NicCs�d}tj}x1|dkrB|d|d@�|}|d?}qWx:tt|��D]}||dkrVPqVqVWd}d}||}|dkr�t|�|r�|t|�|d|}n|S(s�Convert a long integer to a byte string.
If optional blocksize is given and greater than zero, pad the front
of the byte string with binary zeros so that the length is a multiple
of blocksize.
tis>II����i t(tstructtpacktrangetlen(tnt blocksizetsRti((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyt_long2bytesBigEndians
c Cs�t|�d}dg|}d}d}x�||kr�t||�d>}t||d�d>}t||d�d>}t||d�}||B|B|B||<|d}|d}q,W|S( s4Transform a list of characters into a list of longs.iiiiiiii(Rtord( tlisttimaxthltjR tb0tb1tb2tb3((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyt_bytelist2longBigEndian:s
cCs||>|d|?BS(s)Rotate x (32 bit) left n bits circularly.i ((txR((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyt_rotateLeftNscCs||@||@BS(N((tBtCtD((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pytf0_19YscCs||A|AS(N((RRR((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pytf20_39\scCs||@||@B||@BS(N((RRR((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pytf40_59_scCs||A|AS(N((RRR((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pytf60_79bsi�y�Zi���nIܼ�I�b�tshacBs]eZdZdZZdZd�Zd�Zd�Zd�Z d�Z
d�Zd �ZRS(
s:An implementation of the MD5 hash function in pure Python.iicCs/d|_ddg|_g|_|j�dS(sInitialisation.iN(tlengthtcounttinputtinit(tself((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyt__init__vs cCsCd|_g|_d|_d|_d|_d|_d|_dS(s9Initialize the message-digest and set all fields to zero.ii#EgI����I�ܺ�ivT2I����N(RR!tH0tH1tH2tH3tH4(R#((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyR"�s c Cs�x]tdd�D]L}|jt||d||dA||dA||dAd�d@�qW|j}|j}|j}|j}|j}xztdd �D]i}t|d
�||@||@B|||td}|}|}t|d�d@}|}|d@}q�Wxutd d�D]d}t|d
�||A|A|||td}|}|}t|d�d@}|}|d@}qWx�tdd
�D]p}t|d
�||@||@B||@B|||td}|}|}t|d�d@}|}|d@}q�Wxutd
d�D]d}t|d
�||A|A|||td}|}|}t|d�d@}|}|d@}qW|j|d@|_|j|d@|_|j|d@|_|j|d@|_|j|d@|_dS(NiiPiiiiI����iiiii(i<i( RtappendRR%R&R'R(R)tK( R#tWtttARRRtEtTEMP((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyt
_transform�sR A
4/;/cCsRt|�}|jdd?d@}|jd|d>|jd<|jd|d>kro|jdd|jd<n|jd|d?|jd<d|}||kr2t|| �|j|)|jt|j��|}xw|d|kr|jtt|||d!���|d}q�Wt|||!�|_nd}|jt|�|_dS(s�Add to the current message.
Update the md5 object with the string arg. Repeated calls
are equivalent to a single call with the concatenation of all
the arguments, i.e. m.update(a); m.update(b) is equivalent
to m.update(a+b).
The hash is immediately calculated for all full blocks. The final
calculation is made in digest(). It will calculate 1-2 blocks,
depending on how much padding we have to add. This allows us to
keep an intermediate value for the hash, so that we only need to
make minimal recalculation if we call update() to add more data
to the hashed string.
iii?iii@N(RR RR!R1R(R#tinBuftleninBuftindextpartLenR ((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pytupdate�s"
$c
Cs]|j}|j}|j}|j}|j}g|j}g|j}|jdd?d@}|dkrud|} n
d|} dgdgd}
|j|
| �t|jd �|}|j |�t
|jd�t
|jd�t
|jd�t
|jd�t
|jd�}||_||_||_||_||_||_||_|S( s�Terminate the message-digest computation and return digest.
Return the digest of the strings passed to the update()
method so far. This is a 16-byte string which may contain
non-ASCII characters, including null bytes.
iii?i8ixs�Ri(R%R&R'R(R)R!R R6RR1R
(
R#R%R&R'R(R)R!R R4tpadLentpaddingtbitstdigest((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyR:�s2
? cCs0djg|j�D]}dt|�^q�S(sTerminate and return digest in HEX form.
Like digest() except the digest is returned as a string of
length 32, containing only hexadecimal digits. This may be
used to exchange the value safely in email or other non-
binary environments.
Rs%02x(tjoinR:R(R#tc((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyt hexdigest0scCs
tj|�S(s�Return a clone object.
Return a copy ('clone') of the md5 object. This can be used
to efficiently compute the digests of strings that share
a common initial substring.
(tcopytdeepcopy(R#((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyR>:s(
t__name__t
__module__t__doc__tdigest_sizet
digestsizet
block_sizeR$R"R1R6R:R=R>(((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyRps
B + 1
iicCs#t�}|r|j|�n|S(saReturn a new sha crypto object.
If arg is present, the method call update(arg) is made.
(RR6(targtcrypto((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pytnewQs t__main__sjust a test stringt(da39a3ee5e6b4b0d3255bfef95601890afd80709t(3f0cf2e3d9e5903e839417dfc47fed6bfa6457f6t(0852b254078fe3772568a4aba37b917f3d4066bait(8862c1b50967f39d3db6bdc2877d9ccebd3102e5((RBt__date__t__version__RR>R
RRRRRRtfR+RRCRDRtNoneRHR@ta_strR=tAssertionErrorRR6(((sE/usr/lib/python2.7/site-packages/setuptools/_backport/hashlib/_sha.pyt<module>s8
" �
"