File: //usr/local/CyberPanel/lib/python3.10/site-packages/django/utils/__pycache__/crypto.cpython-310.pyc
o
�h� � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z G dd� de
�Zddd �d
d�ZdZ
e
fd
d�Zdd� Zddd�Ze ejd�rOejZejZdS ddd�dd�Zdd�dd�ZdS )z3
Django's standard crypto functions and utilities.
� N)�settings)�force_bytes)�func_supports_parameterc @ s e Zd ZdZdS )�InvalidAlgorithmz&Algorithm is not supported by hashlib.N)�__name__�
__module__�__qualname__�__doc__� r
r
�I/usr/local/CyberPanel/lib/python3.10/site-packages/django/utils/crypto.pyr
s r �sha1)� algorithmc
C sx |du rt j}t| �} t|�}ztt|�}W n ty) } ztd| �|�d}~ww || | ��� }tj |t|�|d�S )a*
Return the HMAC of 'value', using a key generated from key_salt and a
secret (which defaults to settings.SECRET_KEY). Default algorithm is SHA1,
but any algorithm name supported by hashlib can be passed.
A different key_salt should be passed in for every application of HMAC.
Nz6%r is not an algorithm accepted by the hashlib module.)�msg� digestmod)
r �
SECRET_KEYr �getattr�hashlib�AttributeErrorr �digest�hmac�new)�key_salt�value�secretr
�hasher�e�keyr
r
r �salted_hmac s ����r �>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789c s d� � fdd�t| �D ��S )aG
Return a securely generated random string.
The bit length of the returned value can be calculated with the formula:
log_2(len(allowed_chars)^length)
For example, with default `allowed_chars` (26+26+10), this gives:
* length: 12, bit length =~ 71 bits
* length: 22, bit length =~ 131 bits
� c 3 s � | ]}t �� �V qd S �N)�secrets�choice)�.0�i��
allowed_charsr
r � <genexpr>>