Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/itsdangerous/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/itsdangerous/__pycache__/signer.cpython-312.pyc

�

'ٜg�%����ddlmZddlmZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddlmZGd	�d
�ZGd�de�Zddd
�ZGd�de�Z				dd�ZGd�d�Zy)�)�annotationsN�)�_base64_alphabet)�
base64_decode)�
base64_encode)�
want_bytes)�BadSignaturec� �eZdZdZdd�Zdd�Zy)�SigningAlgorithmzgSubclasses must implement :meth:`get_signature` to provide
    signature generation functionality.
    c��t��)z2Returns the signature for the given key and value.)�NotImplementedError��self�key�values   �>/usr/local/lib/python3.12/site-packages/itsdangerous/signer.py�
get_signaturezSigningAlgorithm.get_signatures��!�#�#�c�N�tj||j||��S)zMVerifies the given signature matches the expected
        signature.
        )�hmac�compare_digestr)rrr�sigs    r�verify_signaturez!SigningAlgorithm.verify_signatures$���"�"�3��(:�(:�3��(F�G�GrN�r�bytesrr�returnr)rrrrrrr�bool)�__name__�
__module__�__qualname__�__doc__rr�rrrrs���$�Hrrc��eZdZdZdd�Zy)�
NoneAlgorithmz`Provides an algorithm that does not perform any signing and
    returns an empty signature.
    c��y)Nrr"rs   rrzNoneAlgorithm.get_signature$s��rNr)rrr r!rr"rrr$r$s���rr$c�,�tj|�S)z�Don't access ``hashlib.sha1`` until runtime. FIPS builds may not include
    SHA-1, in which case the import and use as a default would fail before the
    developer can configure something else.
    )�hashlib�sha1)�strings r�
_lazy_sha1r*(s��
�<�<���rc�>�eZdZUdZee�Zded<ddd�Zd	d�Z	y)
�
HMACAlgorithmz*Provides signature generation using HMACs.�t.Any�default_digest_methodNc�.�|�|j}||_y�N)r.�
digest_method)rr1s  r�__init__zHMACAlgorithm.__init__8s��� � �6�6�M�$1��rc�f�tj|||j��}|j�S)N)�msg�	digestmod)r�newr1�digest)rrr�macs    rrzHMACAlgorithm.get_signature>s&���h�h�s���1C�1C�D���z�z�|�rr0)r1r-r)
rrr r!�staticmethodr*r.�__annotations__r2rr"rrr,r,0s!��4�
$0�
�#;��5�;�2�rr,c��t|ttf�rt|�gS|D�cgc]
}t|���c}Scc}wr0)�
isinstance�strrr)�
secret_key�ss  r�_make_keys_listr@Cs<���*�s�E�l�+��:�&�'�'�#-�.�:�a�J�q�M�:�.�.��.s�<c��eZdZUdZee�Zded<dZded<					d											dd�Z	e
dd	��Zddd
�Zdd�Z
dd�Zdd
�Zdd�Zdd�Zy)�Signera�A signer securely signs bytes, then unsigns them to verify that
    the value hasn't been changed.

    The secret key should be a random string of ``bytes`` and should not
    be saved to code or version control. Different salts should be used
    to distinguish signing in different contexts. See :doc:`/concepts`
    for information about the security of the secret key and salt.

    :param secret_key: The secret key to sign and verify with. Can be a
        list of keys, oldest to newest, to support key rotation.
    :param salt: Extra key to combine with ``secret_key`` to distinguish
        signatures in different contexts.
    :param sep: Separator between the signature and value.
    :param key_derivation: How to derive the signing key from the secret
        key and salt. Possible values are ``concat``, ``django-concat``,
        or ``hmac``. Defaults to :attr:`default_key_derivation`, which
        defaults to ``django-concat``.
    :param digest_method: Hash function to use when generating the HMAC
        signature. Defaults to :attr:`default_digest_method`, which
        defaults to :func:`hashlib.sha1`. Note that the security of the
        hash alone doesn't apply when used intermediately in HMAC.
    :param algorithm: A :class:`SigningAlgorithm` instance to use
        instead of building a default :class:`HMACAlgorithm` with the
        ``digest_method``.

    .. versionchanged:: 2.0
        Added support for key rotation by passing a list to
        ``secret_key``.

    .. versionchanged:: 0.18
        ``algorithm`` was added as an argument to the class constructor.

    .. versionchanged:: 0.14
        ``key_derivation`` and ``digest_method`` were added as arguments
        to the class constructor.
    r-r.�
django-concatr=�default_key_derivationNc�<�t|�|_t|�|_|jtvrtd��|�t|�}nd}||_|�|j}||_|�|j}||_
|�t|j�}||_y)Nz�The given separator cannot be used because it may be contained in the signature itself. ASCII letters, digits, and '-_=' must not be used.�itsdangerous.Signer)
r@�secret_keysr�sepr�
ValueError�saltrD�key_derivationr.r1r,�	algorithm)rr>rJrHrKr1rLs       rr2zSigner.__init__�s���)8�
�(C���$�S�/����8�8�'�'��7��
����d�#�D�)�D���	��!�!�8�8�N�#1���� � �6�6�M�$1�����%�d�&8�&8�9�I�+4��rc� �|jdS)z�The newest (last) entry in the :attr:`secret_keys` list. This
        is for compatibility from before key rotation support was added.
        ���)rG)rs rr>zSigner.secret_key�s��
����#�#rc�|�|�|jd}nt|�}|jdk(rDtjt
|j
|j|z�j��S|jdk(rGtjt
|j
|jdz|z�j��S|jdk(rLtj||j��}|j|j�|j�S|jdk(r|Std��)	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.

        :param secret_key: A specific secret key to derive from.
            Defaults to the last item in :attr:`secret_keys`.

        .. versionchanged:: 2.0
            Added the ``secret_key`` parameter.
        rN�concatrCssignerr)r5�nonezUnknown key derivation method)
rGrrK�t�castrr1rJr7rr6�update�	TypeError)rr>r8s   r�
derive_keyzSigner.derive_key�s�����)�)�"�-�J�#�J�/�J����(�*��6�6�%��!3�!3�D�I�I�
�4J�!K�!R�!R�!T�U�U�
�
 �
 �O�
3��6�6��t�)�)�$�)�)�i�*?�*�*L�M�T�T�V��
��
 �
 �F�
*��(�(�:��1C�1C�D�C��J�J�t�y�y�!��:�:�<��
�
 �
 �F�
*����;�<�<rc��t|�}|j�}|jj||�}t	|�S)z*Returns the signature for the given value.)rrVrLrr)rrrrs    rrzSigner.get_signature�s9���5�!���o�o����n�n�*�*�3��6���S�!�!rc�Z�t|�}||jz|j|�zS)zSigns the given string.)rrHr)rrs  r�signzSigner.sign�s+���5�!���t�x�x��$�"4�"4�U�";�;�;rc���	t|�}t|�}t|j�D]2}|j|�}|jj|||�s�2yy#t$rYywxYw)z+Verifies the signature for the given value.FT)r�	Exceptionr�reversedrGrVrLr)rrrr>rs     rrzSigner.verify_signature�sr��	���$�C��5�!��"�4�#3�#3�4�J��/�/�*�-�C��~�~�.�.�s�E�3�?��	5����	��	�s�A#�#	A/�.A/c���t|�}|j|vrtd|j�d���|j|jd�\}}|j	||�r|Std|�d�|���)zUnsigns the given string.zNo z found in valuerz
Signature z does not match)�payload)rrHr	�rsplitr)r�signed_valuerrs    r�unsignz
Signer.unsign�su��!�,�/���8�8�<�'���T�X�X�L��@�A�A�!�(�(����1�5�
��s�� � ���,��L��Z��w�o�>��N�Nrc�F�	|j|�y#t$rYywxYw)znOnly validates the given signed value. Returns ``True`` if
        the signature exists and is valid.
        TF)rar	)rr`s  r�validatezSigner.validates(��	��K�K��%����	��	�s��	 � )rF�.NNN)r>�7str | bytes | cabc.Iterable[str] | cabc.Iterable[bytes]rJ�str | bytes | NonerH�str | bytesrKz
str | Noner1zt.Any | NonerLzSigningAlgorithm | None)rrr0)r>rfrr)rrgrr)rrgrrgrr)r`rgrr)r`rgrr)rrr r!r9r*r.r:rDr2�propertyr>rVrrYrrarcr"rrrBrBLs���#�V$0�
�#;��5�;�#2��C�1�
$:��%)�&*�-1�,5�K�,5�!�,5��	,5�
#�,5�$�
,5�+�,5�\�$��$�=�B"�<�
�"O�rrB)r)r)rrr-)r>rerzlist[bytes])�
__future__r�collections.abc�abc�cabcr'r�typingrR�encodingrrrr�excr	rr$r*r,r@rBr"rr�<module>rpso��"�����&�#�#� ��
H�
H� �$�� ��$��&/�G�/��/�~�~r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists