ok

Mini Shell

Direktori : /usr/lib64/python2.7/
Upload File :
Current File : //usr/lib64/python2.7/hashlib.pyc

�
zfc@s�dZdZee�Zee�ZeZedZd�Zd
ed�Z	y.ddl
Z
e	ZeZej
e
j�ZWnek
r�eZeZnXxUeD]MZyee�e�e<Wq�ek
r�ddlZejde�q�Xq�Wyddl
mZWnsek
r{ddlZddlZd
jd�ed�D��Zd
jd�ed�D��Zdd�ZnX[[[[	[dS(sbhashlib module - A common interface to many hash functions.

new(name, string='', usedforsecurity=True)
     - returns a new hash object implementing the given hash function;
       initializing the hash using the given string data.

       "usedforsecurity" is a non-standard extension for better supporting
       FIPS-compliant environments (see below)

Named constructor functions are also available, these are much faster
than using new():

md5(), sha1(), sha224(), sha256(), sha384(), and sha512()

More algorithms may be available on your platform but the above are guaranteed
to exist.  See the algorithms_guaranteed and algorithms_available attributes
to find out what algorithm names can be passed to new().

NOTE: If you want the adler32 or crc32 hash functions they are available in
the zlib module.

Choose your hash function wisely.  Some have known collision weaknesses.
sha384 and sha512 will be slow on 32 bit platforms.

Our implementation of hashlib uses OpenSSL.

OpenSSL has a "FIPS mode", which, if enabled, may restrict the available hashes
to only those that are compliant with FIPS regulations.  For example, it may
deny the use of MD5, on the grounds that this is not secure for uses such as
authentication, system integrity checking, or digital signatures.

If you need to use such a hash for non-security purposes (such as indexing into
a data structure for speed), you can override the keyword argument
"usedforsecurity" from True to False to signify that your code is not relying
on the hash for security purposes, and this will allow the hash to be usable
even in FIPS mode.  This is not a standard feature of Python 2.7's hashlib, and
is included here to better support FIPS mode.

Hash objects have these methods:
 - update(arg): Update the hash object with the string arg. Repeated calls
                are equivalent to a single call with the concatenation of all
                the arguments.
 - digest():    Return the digest of the strings passed to the update() method
                so far. This may contain non-ASCII characters, including
                NUL bytes.
 - hexdigest(): Like digest() except the digest is returned as a string of
                double length, containing only hexadecimal digits.
 - copy():      Return a copy (clone) of the hash object. This can be used to
                efficiently compute the digests of strings that share a common
                initial substring.

For example, to obtain the digest of the string 'Nobody inspects the
spammish repetition':

    >>> import hashlib
    >>> m = hashlib.md5()
    >>> m.update("Nobody inspects")
    >>> m.update(" the spammish repetition")
    >>> m.digest()
    '\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'

More condensed:

    >>> hashlib.sha224("Nobody inspects the spammish repetition").hexdigest()
    'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'

tmd5tsha1tsha224tsha256tsha384tsha512tnewtalgorithms_guaranteedtalgorithms_availablet
algorithmstpbkdf2_hmaccCsIy(ttd|�}|dt�|SWnttfk
rD�nXdS(Ntopenssl_tusedforsecurity(tgetattrt_hashlibtFalsetAttributeErrort
ValueError(tnametf((s/usr/lib64/python2.7/hashlib.pyt__get_openssl_constructorYs
tcCs2ytj|||�SWntk
r-�nXdS(s�new(name, string='', usedforsecurity=True) - Return a new hashing object
    using the named algorithm; optionally initialized with a string.
    
    Override 'usedforsecurity' to False when using for non-security purposes in
    a FIPS environment
    N(RRR(RtstringR((s/usr/lib64/python2.7/hashlib.pyt
__hash_newjs
i����Nscode for hash %s was not found.(R
ccs|]}t|dA�VqdS(i\N(tchr(t.0tx((s/usr/lib64/python2.7/hashlib.pys	<genexpr>�siccs|]}t|dA�VqdS(i6N(R(RR((s/usr/lib64/python2.7/hashlib.pys	<genexpr>�scCsCt|t�st|��nt|ttf�sHtt|��}nt|ttf�srtt|��}nt|�}t|�}t|dd�}t|�|kr�t||�j	�}n|d|t|�}|j
|jt��|j
|jt
��||d�}|dkr4t|��n|dkrL|j}n|dkrgt|��ndt|�jd}	d}
d}x�t|
�|kr:||tjd	|��}ttj|�d
�}
x@t|d�D].}||�}|
ttj|�d
�N}
q�W|d7}|
tj|	|
�7}
q�W|
| S(s�Password based key derivation function 2 (PKCS #5 v2.0)

        This Python implementations based on the hmac module about as fast
        as OpenSSL's PKCS5_PBKDF2_HMAC for short passwords and much faster
        for long passwords.
        t
block_sizei@scSsB|j�}|j�}|j|�|j|j��|j�S(N(tcopytupdatetdigest(tmsgtinnertouterticpytocpy((s/usr/lib64/python2.7/hashlib.pytprf�s

is%%0%ixiRs>IiN(t
isinstancetstrt	TypeErrortbytest	bytearraytbufferRR
tlenRRt	translatet	_trans_36t	_trans_5CRtNonetdigest_sizetstructtpacktinttbinasciithexlifytxranget	unhexlify(t	hash_nametpasswordtsaltt
iterationstdklenR R!t	blocksizeR$thex_format_stringtdkeytlooptprevtrkeyti((s/usr/lib64/python2.7/hashlib.pyR
�sB	 
(RRRRRR(RRRR	R
(t__doc__t__always_supportedtsetRRR	t__all__RtTrueRRRt
__get_hashtuniontopenssl_md_meth_namestImportErrort__py_newt__get_builtin_constructort__func_nametglobalsRtloggingt	exceptionR
R4R1tjointrangeR.R-R/(((s/usr/lib64/python2.7/hashlib.pyt<module>IsD	




9	

Zerion Mini Shell 1.0