Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
signer.cpython-313.pyc94 linesDownload Raw Back to __pycache__
1�

2��j�%����SSKJr SSKJr SSKrSSKrSSKrSSK	J3r4 SSK	Jr SSK	Jr SSK	J
r
 SSKJr "S	S55r"SS\5rSSS
jjr"SS\5rSSjr"SS5rg)�)�annotationsN�)�_base64_alphabet)�
base64_decode)�
base64_encode)�6want_bytes)�BadSignaturec�,�\rSrSrSrSSjrSSjrSrg)	�SigningAlgorithm�z_Subclasses must implement :meth:`get_signature` to provide7signature generation functionality.8c��[5e)z2Returns the signature for the given key and value.)�NotImplementedError��self�key�values   �YD:\code\apps\devtools\python\user_packages\Python313\site-packages\itsdangerous/signer.py�
get_signature�SigningAlgorithm.get_signatures��!�#�#�c�L�[R"X0RX55$)z=Verifies the given signature matches the expected9signature.10)�hmac�compare_digestr)rrr�sigs    r�verify_signature�!SigningAlgorithm.verify_signatures ���"�"�3�(:�(:�3�(F�G�Gr�N�r�bytesrr�returnr)rrrrrrr �bool)�__name__�11__module__�__qualname__�__firstlineno__�__doc__rr�__static_attributes__rrrrrs���$�Hrrc�"�\rSrSrSrSSjrSrg)�
NoneAlgorithm�zXProvides an algorithm that does not perform any signing and12returns an empty signature.13c��g)Nrrrs   rr�NoneAlgorithm.get_signature$s��rrNr)r"r#r$r%r&rr'rrrr)r)s���rr)c�.�[R"U5$)z�Don't access ``hashlib.sha1`` until runtime. FIPS builds may not include14SHA-1, in which case the import and use as a default would fail before the15developer can configure something else.16)�hashlib�sha1)�strings r�17_lazy_sha1r1(s��18�<�<���rc�L�\rSrSr%Sr\"\5rS\S'S	S19Sjjr	SSjr20Srg)�
HMACAlgorithm�0z*Provides signature generation using HMACs.�t.Any�default_digest_methodNc�.�UcURnXlg�N)r6�
digest_method)rr9s  r�__init__�HMACAlgorithm.__init__8s��� � �6�6�M�$1�rc�`�[R"XURS9nUR5$)N)�msg�	digestmod)r�newr9�digest)rrr�macs    rr�HMACAlgorithm.get_signature>s$���h�h�s��1C�1C�D���z�z�|�r)r9r8)r9r5r)r"r#r$r%r&�staticmethodr1r6�__annotations__r:rr'rrrr3r30s!��4�21$0�22�#;��5�;�2�rr3c��[U[[45(a[U5/$UVs/sHn[U5PM sn$s snfr8)�23isinstance�strrr)�24secret_key�ss  r�_make_keys_listrJCs?���*�s�E�l�+�+��:�&�'�'�#-�.�:�a�J�q�M�:�.�.��.s�Ac���\rSrSr%Sr\"\5rS\S'Sr	S\S'SSS	jjr25\SS26j5rSSSjjr
SSjrSS
jrSSjrSSjrSSjrSrg)�Signer�La^A signer securely signs bytes, then unsigns them to verify that27the value hasn't been changed.28 29The secret key should be a random string of ``bytes`` and should not30be saved to code or version control. Different salts should be used31to distinguish signing in different contexts. See :doc:`/concepts`32for information about the security of the secret key and salt.33 34:param secret_key: The secret key to sign and verify with. Can be a35    list of keys, oldest to newest, to support key rotation.36:param salt: Extra key to combine with ``secret_key`` to distinguish37    signatures in different contexts.38:param sep: Separator between the signature and value.39:param key_derivation: How to derive the signing key from the secret40    key and salt. Possible values are ``concat``, ``django-concat``,41    or ``hmac``. Defaults to :attr:`default_key_derivation`, which42    defaults to ``django-concat``.43:param digest_method: Hash function to use when generating the HMAC44    signature. Defaults to :attr:`default_digest_method`, which45    defaults to :func:`hashlib.sha1`. Note that the security of the46    hash alone doesn't apply when used intermediately in HMAC.47:param algorithm: A :class:`SigningAlgorithm` instance to use48    instead of building a default :class:`HMACAlgorithm` with the49    ``digest_method``.50 51.. versionchanged:: 2.052    Added support for key rotation by passing a list to53    ``secret_key``.54 55.. versionchanged:: 0.1856    ``algorithm`` was added as an argument to the class constructor.57 58.. versionchanged:: 0.1459    ``key_derivation`` and ``digest_method`` were added as arguments60    to the class constructor.61r5r6�
django-concatrG�default_key_derivationNc�@�[U5Ul[U5UlUR[;a[S5eUb[U5nOSnX lUcURnX@lUcURnXPl62Uc[UR5nX`lg)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)
rJ�secret_keysr�sepr�63ValueError�saltrO�key_derivationr6r9r3�	algorithm)rrHrUrSrVr9rWs       rr:�Signer.__init__�s���)8�64�(C���$�S�/����8�8�'�'��7��
����d�#�D�)�D��	��!�!�8�8�N�#1��� � �6�6�M�$1����%�d�&8�&8�9�I�+4�rc� �URS$)zThe newest (last) entry in the :attr:`secret_keys` list. This65is for compatibility from before key rotation support was added.66�����)rR)rs rrH�Signer.secret_key�s��67����#�#rc��UcURSnO[U5nURS:XaE[R"[68UR
URU-5R55$URS:XaH[R"[69UR
URS-U-5R55$URS:XaI[R"XRS9nURUR5 UR5$URS:XaU$[S5e)	a�This method is called to derive the key. The default key70derivation choices can be overridden here. Key derivation is not71intended to be used as a security method to make a complex key72out of a short password. Instead you should use large random73secret keys.74 75:param secret_key: A specific secret key to derive from.76    Defaults to the last item in :attr:`secret_keys`.77 78.. versionchanged:: 2.079    Added the ``secret_key`` parameter.80rZ�concatrNssignerr)r>�nonezUnknown key derivation method)
rRrrV�t�castrr9rUr@rr?�update�	TypeError)rrHrAs   r�81derive_key�Signer.derive_key�s�����)�)�"�-�J�#�J�/�J����(�*��6�6�%��!3�!3�D�I�I�82�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��[U5nUR5nURRX!5n[	U5$)z*Returns the signature for the given value.)rrcrWrr)rrrrs    rr�Signer.get_signature�s7���5�!���o�o����n�n�*�*�3�6���S�!�!rc�X�[U5nXR-URU5-$)zSigns the given string.)rrSr)rrs  r�sign�Signer.sign�s)���5�!���x�x��$�"4�"4�U�";�;�;rc���[U5n[U5n[UR5H7nURU5nURRXAU5(dM7 g g![a gf=f)z+Verifies the signature for the given value.FT)r�	Exceptionr�reversedrRrcrWr)rrrrHrs     rr�Signer.verify_signature�ss��	���$�C��5�!��"�4�#3�#3�4�J��/�/�*�-�C��~�~�.�.�s�3�?�?��	5����	��	�s�A)�)83A6�5A6c���[U5nURU;a[SUR<S35eURURS5up#UR	X#5(aU$[SU<S3US9e)zUnsigns the given string.zNo z found in valuerz84Signature z does not match)�payload)rrSr	�rsplitr)r�signed_valuerrs    r�unsign�
Signer.unsign�st��!�,�/���8�8�<�'���T�X�X�L��@�A�A�!�(�(����1�5�85��� � ��,�,��L��Z��w�o�>��N�Nrc�H�URU5 g![a gf=f)z^Only validates the given signed value. Returns ``True`` if86the signature exists and is valid.87TF)rrr	)rrqs  r�validate�Signer.validates(��	��K�K��%����	��	�s��88!�!)rWr9rVrUrRrS)rQ�.NNN)rH�7str | bytes | cabc.Iterable[str] | cabc.Iterable[bytes]rU�str | bytes | NonerS�str | bytesrVz89str | Noner9zt.Any | NonerWzSigningAlgorithm | None)r rr8)rHryr r)rrzr r)rrzrrzr r!)rqrzr r)rqrzr r!)r"r#r$r%r&rCr1r6rDrOr:�propertyrHrcrrhrrrrur'rrrrLrLLs���#�V$0�90�#;��5�;�#2��C�1�91$:��%)�&*�-1�,5�K�,5�!�,5��	,5�92#�,5�$�
,5�+�,5�\�$��$�=�B"�<�93�"O�rrL)r)r0rr r5)rHrxr zlist[bytes])�94__future__r�collections.abc�abc�cabcr.r�typingr_�encodingrrrr�excr	rr)r1r3rJrLrrr�<module>r�so��"�����&�#�#� ��
H�
H� �$�� ��$��&/�G�/��/�~�~r
codekingpro/portable-devtools · Team Ai