Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/itsdangerous/__pycache__/signer.cpython-39.pyc
Ðазад
a g�h� � @ s� d dl Z d dlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z G d d � d e�ZG dd� de�Z G d d� de�ZG dd� de�ZdS )� N� )�constant_time_compare)�_base64_alphabet)� base64_decode)� base64_encode)� want_bytes)�BadSignaturec @ s e Zd ZdZdd� Zdd� ZdS )�SigningAlgorithmzgSubclasses must implement :meth:`get_signature` to provide signature generation functionality. c C s t � �dS )z2Returns the signature for the given key and value.N)�NotImplementedError��self�key�value� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/itsdangerous/signer.py� get_signature s zSigningAlgorithm.get_signaturec C s t || �||��S )zMVerifies the given signature matches the expected signature. )r r )r r r �sigr r r �verify_signature s z!SigningAlgorithm.verify_signatureN)�__name__� __module__�__qualname__�__doc__r r r r r r r s r c @ s e Zd ZdZdd� ZdS )� NoneAlgorithmz`Provides an algorithm that does not perform any signing and returns an empty signature. c C s dS )N� r r r r r r ! s zNoneAlgorithm.get_signatureN)r r r r r r r r r r s r c @ s, e Zd ZdZeej�Zddd�Zdd� Z dS )� HMACAlgorithmz*Provides signature generation using HMACs.Nc C s |d u r| j }|| _d S )N)�default_digest_method� digest_method)r r r r r �__init__- s zHMACAlgorithm.__init__c C s t j||| jd�}|�� S )N)�msg� digestmod)�hmac�newr �digest)r r r �macr r r r 2 s zHMACAlgorithm.get_signature)N) r r r r �staticmethod�hashlib�sha1r r r r r r r r % s r c @ sX e Zd ZdZeej�ZdZddd�Z dd� Z d d � Zdd� Zd d� Z dd� Zdd� ZdS )�Signera� This class can sign and unsign bytes, validating the signature provided. Salt can be used to namespace the hash, so that a signed string is only valid for a given namespace. Leaving this at the default value or re-using a salt value across different parts of your application where the same signed value in one part can mean something different in another part is a security risk. See :ref:`the-salt` for an example of what the salt is doing and how you can utilize it. .. versionadded:: 0.14 ``key_derivation`` and ``digest_method`` were added as arguments to the class constructor. .. versionadded:: 0.18 ``algorithm`` was added as an argument to the class constructor. � django-concatN�.c C s| t |�| _t |�| _| jtv r&td��|d u r2dn|| _|d u rF| j}|| _|d u rZ| j}|| _ |d u rrt | j �}|| _d S )Nz�The given separator cannot be used because it may be contained in the signature itself. Alphanumeric characters and `-_=` must not be used.zitsdangerous.Signer)r � secret_key�sepr � ValueError�salt�default_key_derivation�key_derivationr r r � algorithm)r r* r- r+ r/ r r0 r r r r [ s � zSigner.__init__c C s� t | j�}| jdkr(| �|| j ��� S | jdkrJ| �|d | j ��� S | jdkrxtj| j| jd�}|�|� |�� S | jdkr�| jS t d��dS ) a+ This method is called to derive the key. The default key derivation choices can be overridden here. Key derivation is not intended to be used as a security method to make a complex key out of a short password. Instead you should use large random secret keys. �concatr( s signerr )r �nonezUnknown key derivation methodN) r r- r/ r r* r"