python-pae
Submodules
Members
This is the main entry point for the PAE encoding/decoding API.
- python_pae.pae_encode(lst: List[bytes], size_t: python_pae.number.PAENumberType = <uint64 (ULLONG)>) bytes
Encode a list of byte strings in PAE.
Note
By default, this function produces output that is compatible with PASETO PAE.
- Parameters
lst – A list of byte strings.
size_t – Numeric type to use for the list’s size and its members’ length prefixes.
- Returns
The PAE-encoded list as a byte string.
- python_pae.pae_encode_multiple(value_type_pairs, size_t: python_pae.number.PAENumberType = <uint64 (ULLONG)>) bytes
Encode a list of multiple typed values in PAE.
- Parameters
value_type_pairs – A list of tuples of the form
(v, t)
, wherev
is a value, andt
is aPAEType
implementation for that value type.size_t – Numeric type to use for the list’s size and its members’ length prefixes.
- Returns
The PAE-encoded list as a byte string.
- python_pae.marshal(value: python_pae.encode.T, pae_type: python_pae.abstract.PAEType[python_pae.encode.T]) bytes
Serialise a value into bytes.
- Parameters
value – The value to be processed.
pae_type – The
PAEType
that provides the serialisation logic.
- Returns
A byte string representing the value passed in.
- python_pae.unmarshal(packed: bytes, pae_type: python_pae.abstract.PAEType[python_pae.encode.T]) python_pae.encode.T
Decode a byte string back into a value. Inverse operation of
marshal()
.- Parameters
packed – The byte string to be processed.
pae_type – The
PAEType
that provides the deserialisation logic.
- Returns
A decoded value.
- Raises
python_pae.PAEDecodeError – if an error occurs in the decoding process.
- class python_pae.PAEListSettings(size_type: python_pae.number.PAENumberType = <uint64 (ULLONG)>, length_type: Optional[python_pae.number.PAENumberType] = None, prefix_if_constant: bool = True)
Bases:
object
List encoding settings. The defaults represent the PASETO version of PAE.
- size_type: python_pae.number.PAENumberType = <uint64 (ULLONG)>
Numeric type to use for the list size.
Note
The default is a 64-bit integer for compatibility with PASETO PAE.
- length_type: Optional[python_pae.number.PAENumberType] = None
Numeric type to use for the length prefixes of the list items.
Note
If unspecified, will be the same as
size_type
.
- prefix_if_constant: bool = True
Flag toggling whether to apply the length prefix if the type being written or read is a fixed-width type. Defaults to
True
.
- exception python_pae.PAEDecodeError
Bases:
ValueError
Raised if an error occurs during PAE decoding.