API Reference¶
A Python implementation of PASETO <https://pyseto.readthedocs.io>
- pyseto.encode(key: pyseto.key_interface.KeyInterface, payload: Union[bytes, str], footer: Union[bytes, str] = b'', implicit_assertion: Union[bytes, str] = b'', nonce: bytes = b'') bytes [source]¶
Encodes a message to a PASETO token with a key.
- Parameters
key (KeyInterface) – A key for encryption or signing.
payload (Union[bytes, str]) – A message to be encrypted or signed.
footer (Union[bytes, str]) – A footer.
implicit_assertion (Union[bytes, str]) – An implicit assertion.
nonce (bytes) – A nonce.
- Returns
A PASETO token.
- Return type
str
- Raises
ValueError – Invalid arguments.
EncryptError – Failed to encrypt the message.
SignError – Failed to sign the message.
- pyseto.decode(keys: Union[pyseto.key_interface.KeyInterface, List[pyseto.key_interface.KeyInterface]], token: Union[bytes, str], implicit_assertion: Union[bytes, str] = b'') pyseto.token.Token [source]¶
Decodes a PASETO token with a key.
- Parameters
key (KeyInterface) – A key for decryption or verifying the signature in the token.
token (Union[bytes, str]) – A PASETO token to be decrypted or verified.
implicit_assertion (Optional[Union[bytes, str]]) – An implicit assertion.
- Returns
A parsed PASETO token object.
- Return type
- Raises
ValueError – Invalid arguments.
DecryptError – Failed to decrypt the message.
VerifyError – Failed to verify the message.
- exception pyseto.DecryptError[source]¶
Bases:
pyseto.exceptions.PysetoError
An Exception occurred when an decryption process failed.
- exception pyseto.EncryptError[source]¶
Bases:
pyseto.exceptions.PysetoError
An Exception occurred when an encryption process failed.
- exception pyseto.NotSupportedError[source]¶
Bases:
pyseto.exceptions.PysetoError
An Exception occurred when the function is not supported for the key object.
- exception pyseto.SignError[source]¶
Bases:
pyseto.exceptions.PysetoError
An Exception occurred when a signing process failed.
- exception pyseto.VerifyError[source]¶
Bases:
pyseto.exceptions.PysetoError
An Exception occurred when a verification process failed.
- class pyseto.key_interface.KeyInterface(version: str, type: str, key: Any)[source]¶
Bases:
object
The key interface class for PASETO.
- property version: str¶
- property type: str¶
- property header: bytes¶