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'.'
.
- 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'.'
.