%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/beaker/crypto/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/beaker/crypto/__pycache__/pbkdf2.cpython-37.pyc

B

��[��@shdZddlmZmZddlZddlZddlZddlZdd�Zdd�Z	e
ed�rZdd	d
�Zn
d
dd
�ZdS)z
PBKDF2 Implementation adapted from django.utils.crypto.

This is used to generate the encryption key for enciphered sessions.
�)�bytes_�xrange_NcCstt�|�d�S)z+Convert a binary string into a long integer�)�int�binascii�hexlify)�x�r	�E/opt/alt/python37/lib/python3.7/site-packages/beaker/crypto/pbkdf2.py�_bin_to_longsrcCst�||�d��S)zw
    Convert a long integer into a binary string.
    hex_format_string is like "%020x" for padding 10 characters.
    �ascii)r�	unhexlify�encode)r�hex_format_stringr	r	r
�_long_to_binsr�pbkdf2_hmaccCs<|dkrtj}|sd}t|�}t|�}t�|�j||||�S)a�
        Implements PBKDF2 using the stdlib. This is used in Python 2.7.8+ and 3.4+.

        HMAC+SHA256 is used as the default pseudo random function.

        As of 2014, 100,000 iterations was the recommended default which took
        100ms on a 2.7Ghz Intel i7 with an optimized implementation. This is
        probably the bare minimum for security given 1000 iterations was
        recommended in 2001.
        N)�hashlib�sha1rr�name)�password�salt�
iterations�dklen�digestr	r	r
�pbkdf2src	s�dkst�|stj}t|�}t���|�j}|s6|}|d|krJtd��||}||d|}d|d�|�|���t|��jkr�||���}|d�jt|�7}��	|�
tj����	|�
tj
�������fdd	���fd
d�td|�D�}d�|��|�d
|�S)a
        Implements PBKDF2 as defined in RFC 2898, section 5.2

        HMAC+SHA256 is used as the default pseudo random function.

        As of 2014, 100,000 iterations was the recommended default which took
        100ms on a 2.7Ghz Intel i7 with an optimized implementation. This is
        probably the bare minimum for security given 1000 iterations was
        recommended in 2001. This code is very well optimized for CPython and
        is about five times slower than OpenSSL's implementation.
        rl��z
dklen too big�z%%0%ix��csr�t�d|�}d}xRtt���D]B}������}}|�|�|�|���|��}|t|�N}q"Wt|��S)Ns>Ir)	�struct�packrr�copy�updaterrr)�i�u�result�jZdig1Zdig2)r�innerr�outerrr	r
�FRs
zpbkdf2.<locals>.Fcsg|]}�|��qSr	r	)�.0r)r(r	r
�
<listcomp>]szpbkdf2.<locals>.<listcomp>�N)�AssertionErrorrrr�digest_size�
OverflowError�len�
block_sizerr!�	translate�hmacZtrans_36Ztrans_5Cr�join)	rrrrrZhlen�l�r�Tr	)r(rr&rr'rr
r0s,)rN)rN)�__doc__Zbeaker._compatrrr2rrrrr�hasattrrr	r	r	r
�<module>s


Zerion Mini Shell 1.0