← Back
Editing: hashers.cpython-311.pyc
� 48zj|b � � � 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 Zd� Zd.d �Zd.d�Z ej � � d� � � Z ej � � d� � � Z ee� � d� � � Z!d/d�Z"d� Z#d0d�Z$d� Z% G d� d� � Z& G d� de&� � Z' G d� de'� � Z( G d� de&� � Z) G d � d!e&� � Z* G d"� d#e*� � Z+ G d$� d%e&� � Z, G d&� d'e&� � Z- G d(� d)e&� � Z. G d*� d+e&� � Z/ G d,� d-e&� � Z0dS )1� N)�settings)�ImproperlyConfigured)�setting_changed)�receiver)�RANDOM_STRING_CHARS�constant_time_compare�get_random_string�pbkdf2)� import_string)�gettext_noop�!�( c �@ � | 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)�encodeds �=/usr/lib/python3/dist-packages/django/contrib/auth/hashers.py�is_password_usabler s% � � �d�?�N�'�"4�"4�5M�"N�"N�N�N� �defaultc � � | du pt |� � }t |� � } t |� � }n# t $ r d}Y nw xY w|r#t t t � � � � dS |j |j k }|p|� |� � }|� | |� � }|s|s|r|� | |� � |r|r |r || � � |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_corrects r �check_passwordr( s" � � �t�#�F�+=�g�+F�+F�'F�L��9�%�%�I�� ��)�)����� � � ��������� � � �'�(G�H�H�I�I�I��u��%��)<�<�N� �B�I�$9�$9�'�$B�$B�K����x��1�1�J� � 1�n� 1�� 1����h��0�0�0� � �*� �� ���x�����s �5 �A�Ac �4 � | �t t t � � z S t | t t f� � s$t dt | � � j z � � �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! r0 r% s r r r G s� � � ��'�*;�<[�*\�*\�\�\��h����-�-� ��9��8�n�n�)� *� � � � �� � �F�� �6�;�;�=�=�D��=�=��4�(�(�(r c �� � g } t j D ]R}t |� � } |� � }t |d� � st d|z � � �| � |� � �S| S )Nr z,hasher doesn't specify an algorithm name: %s)r �PASSWORD_HASHERSr �getattrr �append)�hashers�hasher_path� hasher_clsr% s r �get_hashersr9 \ s� � ��G��0� � ��"�;�/�/� �������v�{�+�+� K�&� (<�>I�(J� K� K� K����v������Nr c �2 � d� t � � D � � S )Nc � � i | ] }|j |��S � �r )�.0r% s r � <dictcomp>z,get_hashers_by_algorithm.<locals>.<dictcomp>k s � �A�A�A��F��f�A�A�Ar )r9 r<