itsdangerous

Safely pass data to untrusted environments and back.

27 个版本 Python >=3.8
安装
pip install itsdangerous
poetry add itsdangerous
pipenv install itsdangerous
conda install itsdangerous
描述

ItsDangerous

... so better sign this

Various helpers to pass data to untrusted environments and to get it back safe and sound. Data is cryptographically signed to ensure that a token has not been tampered with.

It's possible to customize how data is serialized. Data is compressed as needed. A timestamp can be added and verified automatically while loading a token.

A Simple Example

Here's how you could generate a token for transmitting a user's id and name between web requests.

from itsdangerous import URLSafeSerializer
auth_s = URLSafeSerializer("secret key", "auth")
token = auth_s.dumps({"id": 5, "name": "itsdangerous"})

print(token)
# eyJpZCI6NSwibmFtZSI6Iml0c2Rhbmdlcm91cyJ9.6YP6T0BaO67XP--9UzTrmurXSmg

data = auth_s.loads(token)
print(data["name"])
# itsdangerous

The Pallets organization develops and supports ItsDangerous and other popular packages. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects, please donate today.

版本列表
2.2.0 2024-04-16
2.1.2 2022-03-24
2.1.1 2022-03-09
2.1.0 2022-02-18
2.0.1 2021-05-18
2.0.0 2021-05-11
2.0.0rc2 2021-04-16
2.0.0rc1 2021-02-15
2.0.0a1 2020-05-28
1.1.0 2018-10-27
0.24 2014-03-28
0.23 2013-08-08
0.22 2013-07-03
0.21 2013-05-26
0.20 2013-05-23
0.19 2013-05-22
0.18 2013-05-15
0.17 2012-08-11
0.16 2012-07-11
0.15 2012-07-11
0.14 2012-06-29
0.13 2012-06-10
0.12 2012-02-22
0.11 2011-07-07
0.10 2011-06-29
0.9.1 2011-06-26
0.9 2011-06-24