File: //usr/lib/python3/dist-packages/django/contrib/auth/__pycache__/hashers.cpython-310.pyc
o
/�h|b � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl m
Z
d dlmZ d dl
mZ d dlmZmZmZmZ d dlmZ d dlmZ d Zd
Zdd� Zd8dd�Zd8dd�Ze�� dd� �Ze�� dd� �Z ee�dd� �Z!d9dd�Z"dd� Z#d:dd�Z$d d!� Z%G d"d#� d#�Z&G d$d%� d%e&�Z'G d&d'� d'e'�Z(G d(d)� d)e&�Z)G d*d+� d+e&�Z*G d,d-� d-e*�Z+G d.d/� d/e&�Z,G d0d1� d1e&�Z-G d2d3� d3e&�Z.G d4d5� d5e&�Z/G d6d7� d7e&�Z0dS );� N)�settings)�ImproperlyConfigured)�setting_changed)�receiver)�RANDOM_STRING_CHARS�constant_time_compare�get_random_string�pbkdf2)�
import_string)�gettext_noop�!�( c C s | du p | � t� S )zv
Return True if this password wasn't generated by
User.set_unusable_password(), i.e. make_password(None).
N)�
startswith�UNUSABLE_PASSWORD_PREFIX)�encoded� r �=/usr/lib/python3/dist-packages/django/contrib/auth/hashers.py�is_password_usable s r �defaultc C s� | du pt |� }t|�}zt|�}W n ty d}Y nw |r)ttt�� dS |j|jk}|p5|�|�}|� | |�}|sH|sH|rH|�
| |� |rR|rR|rR|| � |S )z�
Return a boolean of whether the raw password matches the three
part encoded digest.
If setter is specified, it'll be called when you need to
regenerate the password.
NTF)r �
get_hasher�identify_hasher�
ValueError�
make_passwordr �UNUSABLE_PASSWORD_SUFFIX_LENGTH� algorithm�must_update�verify�harden_runtime) �passwordr �setter� preferred�fake_runtime�hasher�hasher_changedr �
is_correctr r r �check_password s$ �r% c C sT | du r
t tt� S t| ttf�stdt| �j ��t |�}|p#|�
� }|�| |�S )a|
Turn a plain-text password into a hash for database storage
Same as encode() but generate a new random salt. If password is None then
return a concatenation of UNUSABLE_PASSWORD_PREFIX and a random string,
which disallows logins. Additional random string reduces chances of gaining
access to staff or superuser accounts. See ticket #20079 for more info.
Nz+Password must be a string or bytes, got %s.)r r r �
isinstance�bytes�str� TypeError�type�__qualname__r �salt�encode)r r, r"