[+@sdZdZeeZeeZedZiZd d Zd dZdddZ dddZ y.ddl Z e Z eZ eje jZWnek re Z eZ YnXyddl mZWn_ek r.eddedDZeddedDZddd ZYnXxVeD]NZye eee>> import hashlib >>> m = hashlib.md5() >>> m.update(b"Nobody inspects") >>> m.update(b" the spammish repetition") >>> m.digest() b'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9' More condensed: >>> hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest() 'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2' md5sha1sha224sha256sha384sha512newalgorithms_guaranteedalgorithms_available pbkdf2_hmacc Cs[t}|j|}|dk r%|Sy|dkrXddl}|j|d<|dsr,ccs|]}|dAVqdS)6Nr)r*r+rrrr,scCs1t|tst|nt|ttfsHtt|}nt|ttfsrtt|}nt|}t|}t|dd}t||krt||j }n|d|t|}|j |j t |j |j t ||dd}|dkr7t|n|dkrO|j}n|dkrjt|nd} d} tj} xt| |kr"||| jd d } tj| d } x7t|dD]%}|| } | | | d N} qW| d7} | | j|jd 7} qW| d|S) zPassword 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. Z block_size@scSsB|j}|j}|j||j|j|jS)N)copyupdatedigest)msginnerouterZicpyZocpyrrrprfs    zpbkdf2_hmac..prfNr%Zbig) isinstancestr TypeErrorbytes bytearray memoryviewrr lenr2r1 translate _trans_36 _trans_5CrZ digest_sizeint from_bytesto_bytesrange)Z hash_nameZpasswordZsaltZ iterationsZdklenr4r5Z blocksizer6ZdkeyZlooprDprevZrkeyirrrr sB         zcode for hash %s was not found.)zmd5zsha1zsha224zsha256zsha384zsha512)znewzalgorithms_guaranteedzalgorithms_availablez pbkdf2_hmac)__doc__Z__always_supportedsetrr __all__rrr$r'r(r!rZ __get_hashunionZopenssl_md_meth_namesrr r<rFrBrAZ __func_nameglobalsrZloggingZ exceptionrrrr5sB        :