URL Safe Serialization¶
Often it is helpful if you can pass these trusted strings in places where you only have a limited set of characters available. Because of this, ItsDangerous also provides URL safe serializers:
from itsdangerous.url_safe import URLSafeSerializer
s = URLSafeSerializer("secret-key")
s.dumps([1, 2, 3, 4])
'WzEsMiwzLDRd.wSPHqC0gR7VUqivlSukJ0IeTDgo'
s.loads("WzEsMiwzLDRd.wSPHqC0gR7VUqivlSukJ0IeTDgo")
[1, 2, 3, 4]
- class itsdangerous.url_safe.URLSafeSerializer(secret_key, salt=b'itsdangerous', serializer=None, serializer_kwargs=None, signer=None, signer_kwargs=None, fallback_signers=None)¶
Works like
Serializer
but dumps and loads into a URL safe string consisting of the upper and lowercase character of the alphabet as well as'_'
,'-'
and'.'
.- Parameters
secret_key (Union[Iterable[Union[str, bytes]], str, bytes]) –
salt (Optional[Union[str, bytes]]) –
serializer (Any) –
serializer_kwargs (Dict[str, Any]) –
signer (Type[itsdangerous.signer.Signer]) –
signer_kwargs (Dict[str, Any]) –
fallback_signers (List[Union[Dict[str, Any], Tuple[Type[itsdangerous.signer.Signer], Dict[str, Any]], Type[itsdangerous.signer.Signer]]]) –
- class itsdangerous.url_safe.URLSafeTimedSerializer(secret_key, salt=b'itsdangerous', serializer=None, serializer_kwargs=None, signer=None, signer_kwargs=None, fallback_signers=None)¶
Works like
TimedSerializer
but dumps and loads into a URL safe string consisting of the upper and lowercase character of the alphabet as well as'_'
,'-'
and'.'
.- Parameters
secret_key (Union[Iterable[Union[str, bytes]], str, bytes]) –
salt (Optional[Union[str, bytes]]) –
serializer (Any) –
serializer_kwargs (Dict[str, Any]) –
signer (Type[itsdangerous.signer.Signer]) –
signer_kwargs (Dict[str, Any]) –
fallback_signers (List[Union[Dict[str, Any], Tuple[Type[itsdangerous.signer.Signer], Dict[str, Any]], Type[itsdangerous.signer.Signer]]]) –