o
    j$                     @   s2   d dl mZ d dlZd dl mZ ejfddZdS )    )hmacN)hashlibc                    s   t j| |d  fdd}t }d}t||k rK||td|  }}	t|d D ]}
||	}	tdd t||	D }q*||7 }|d7 }t||k s|d| S )	a  Run the PBKDF2 (Password-Based Key Derivation Function 2) algorithm
	and return the derived key. The arguments are:

	password (bytes or bytearray) -- the input password
	salt (bytes or bytearray) -- a cryptographic salt
	iters (int) -- number of iterations
	keylen (int) -- length of key to derive
	digestmod -- a cryptographic hash function: either a module
		supporting PEP 247, a hashlib constructor, or (in Python 3.4
		or later) the name of a hash function.

	For example:

	>>> import hashlib
	>>> from binascii import hexlify, unhexlify
	>>> password = b'Squeamish Ossifrage'
	>>> salt = unhexlify(b'1234567878563412')
	>>> hexlify(pbkdf2(password, salt, 500, 16, hashlib.sha1))
	b'9e8f1072bdf5ef042bd988c7da83e43b'

	)	digestmodc                    s      }||  t| S N)copyupdate	bytearraydigest)datahmh /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/unicrypto/pbkdf2.pyprf   s   
zpbkdf2.<locals>.prf   z>ic                 s   s    | ]	\}}||A V  qd S r   r   ).0xyr   r   r   	<genexpr>)   s    zpbkdf2.<locals>.<genexpr>N)r   newr   lenstructpackrangezip)passwordsaltiterskeylenr   r   keyiTU_r   r   r   pbkdf2   s   r%   )	unicryptor   r   r   sha1r%   r   r   r   r   <module>   s   