Download tasks/swe-next-5e830173928160b2ece0/tests/source/docs/signer.rst from FineEnvs/repo2rlenv-swe-next: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/datasets/FineEnvs/repo2rlenv-swe-next/resolve/main/tasks/swe-next-5e830173928160b2ece0/tests/source/docs/signer.rst
- Command line
-
hf download hf://datasets/FineEnvs/repo2rlenv-swe-next/tasks/swe-next-5e830173928160b2ece0/tests/source/docs/signer.rst
-
curl -L -o signer.rst https://huggingface.co/datasets/FineEnvs/repo2rlenv-swe-next/resolve/main/tasks/swe-next-5e830173928160b2ece0/tests/source/docs/signer.rst
1.31 kB
| .. module:: itsdangerous.signer | |
| Signing Interface | |
| ================= | |
| The most basic interface is the signing interface. The :class:`Signer` | |
| class can be used to attach a signature to a specific string: | |
| .. code-block:: python | |
| from itsdangerous import Signer | |
| s = Signer("secret-key") | |
| s.sign("my string") | |
| b'my string.wh6tMHxLgJqB6oY1uT73iMlyrOA' | |
| The signature is appended to the string, separated by a dot. To validate | |
| the string, use the :meth:`~Signer.unsign` method: | |
| .. code-block:: python | |
| s.unsign(b"my string.wh6tMHxLgJqB6oY1uT73iMlyrOA") | |
| b'my string' | |
| If unicode strings are provided, an implicit encoding to UTF-8 happens. | |
| However after unsigning you won't be able to tell if it was unicode or | |
| a bytestring. | |
| If the value is changed, the signature will no longer match, and | |
| unsigning will raise a :exc:`~itsdangerous.exc.BadSignature` exception: | |
| .. code-block:: python | |
| s.unsign(b"different string.wh6tMHxLgJqB6oY1uT73iMlyrOA") | |
| Traceback (most recent call last): | |
| ... | |
| itsdangerous.exc.BadSignature: Signature "wh6tMHxLgJqB6oY1uT73iMlyrOA" does not match | |
| To record and validate the age of a signature, see :doc:`/timed`. | |
| .. autoclass:: Signer | |
| :members: | |
| Signing Algorithms | |
| ------------------ | |
| .. autoclass:: NoneAlgorithm | |
| .. autoclass:: HMACAlgorithm | |