AlkantarClanX12
Current Path : /proc/thread-self/root/lib64/python2.7/ |
Current File : //proc/thread-self/root/lib64/python2.7/hashlib.pyo |
� zfc @ s� d Z d Z e e � Z e e � Z e Z e d Z d � Z d e d � Z y. d d l Z e Z e Z e j e j � Z Wn e k r� e Z e Z n XxU e D]M Z y e e � e � e <Wq� e k r� d d l Z e j d e � q� Xq� Wy d d l m Z Wns e k r{d d l Z d d l Z d j d � e d � D� � Z d j d � e d � D� � Z d d � Z n X[ [ [ [ [ d S( sb hashlib 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' t md5t sha1t sha224t sha256t sha384t sha512t newt algorithms_guaranteedt algorithms_availablet algorithmst pbkdf2_hmacc C sI y( t t d | � } | d t � | SWn t t f k rD � n Xd S( Nt openssl_t usedforsecurity( t getattrt _hashlibt Falset AttributeErrort ValueError( t namet f( ( s /usr/lib64/python2.7/hashlib.pyt __get_openssl_constructorY s t c C s2 y t j | | | � SWn t k r- � n Xd S( 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( R R R ( R t stringR ( ( s /usr/lib64/python2.7/hashlib.pyt __hash_newj s i����Ns code for hash %s was not found.( R c c s | ] } t | d A� Vq d S( i\ N( t chr( t .0t x( ( s /usr/lib64/python2.7/hashlib.pys <genexpr>� s i c c s | ] } t | d A� Vq d S( i6 N( R ( R R ( ( s /usr/lib64/python2.7/hashlib.pys <genexpr>� s c C sC t | t � s t | � � n t | t t f � sH t t | � � } n t | t t f � sr t t | � � } n t | � } t | � } t | d d � } t | � | k r� t | | � j � } n | d | t | � } | j | j t � � | j | j t � � | | d � } | d k r4t | � � n | d k rL| j } n | d k rgt | � � n d t | � j d } d } d } x� t | � | k r:| | t j d | � � } t t j | � d � } x@ t | d � D]. } | | � } | t t j | � d � N} q�W| d 7} | t j | | � 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@ s c S sB | j � } | j � } | j | � | j | j � � | j � S( N( t copyt updatet digest( t msgt innert outert icpyt ocpy( ( s /usr/lib64/python2.7/hashlib.pyt prf� s i s %%0%ixi R s >Ii N( t isinstancet strt TypeErrort bytest bytearrayt bufferR R t lenR R t translatet _trans_36t _trans_5CR t Nonet digest_sizet structt packt intt binasciit hexlifyt xranget unhexlify( t hash_namet passwordt saltt iterationst dklenR R! t blocksizeR$ t hex_format_stringt dkeyt loopt prevt rkeyt i( ( s /usr/lib64/python2.7/hashlib.pyR � sB ( R R R R R R ( R R R R R ( t __doc__t __always_supportedt setR R R t __all__R t TrueR R R t __get_hasht uniont openssl_md_meth_namest ImportErrort __py_newt __get_builtin_constructort __func_namet globalsR t loggingt exceptionR R4 R1 t joint rangeR. R- R/ ( ( ( s /usr/lib64/python2.7/hashlib.pyt <module>I sD 9