python-paseto
Platform-Agnostic Security Tokens for Python
Installation
pip install python-paseto
Check installation
python -m paseto
libsodium is required, this will check if it is installed on your system. On Ubuntu 20.04 you can get it with sudo apt install libsodium23.
Low level API
Implements PASETO Version2 and Version4 protocols supporting v2.public, v2.local, v4.public and v4.local messages.
Every protocol version provides access to encrypt() / decrypt() and sign() / verify() functions.
Low level API is focuses on solid, high quality, production ready primitives as specified directly in the PASETO protocol. See paseto-spec for protocol details.
Example use with Version2
from paseto.protocol.version2 import encrypt, decrypt
message = b"foo" # your data
key = b"0" * 32 # encryption key
token = encrypt(message, key)
plain_text = decrypt(token, key)
assert plain_text == message
print(f"token={token}")
print(f"plain_text={plain_text}")
print(f"message={message}")
With optional footer
from paseto.protocol.version2 import encrypt, decrypt
message = b"foo" # your data
key = b"0" * 32 # encryption key
optional_footer = b"sample_footer" # authenticated but not encrypted metadata
token = encrypt(message, key, optional_footer)
plain_text = decrypt(token, key, optional_footer)
assert plain_text == message
print(f"token={token}")
print(f"plain_text={plain_text}")
print(f"message={message}")
Example use with Version4
from paseto.protocol.version4 import create_symmetric_key, decrypt, encrypt
message = b"this is a secret message" # your data
key = create_symmetric_key() # encryption key
token = encrypt(message, key)
plain_text = decrypt(token, key)
assert plain_text == message
print(f"token={token}")
print(f"plain_text={plain_text}")
print(f"message={message}")
Message signing
from paseto.protocol.version4 import create_asymmetric_key, sign, verify
message = b"this is a public message" # your data
public_key, secret_key = create_asymmetric_key() # signing / verifying keys
token = sign(message, secret_key)
verified_message = verify(token, public_key)
assert verified_message == message
print(f"token={token}")
print(f"verified_message={verified_message}")
print(f"message={message}")
High level API
In the future a high level API will provide developer friendly access to low level API and support easy integration into other projects.
Development
Typical dev workflow operations are automated in Makefile, including testing, linting, code quality checks, benchmarks and dev environment setup.
Contributing
This library is under active development and maintenance. For any feedback, questions, comments or if you would like to request a feature, please raise an issue!
Metadata
Release files for python-paseto 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-paseto-0.5.2.tar.gz | 11.2 kB | Without provenance | Details for python-paseto-0.5.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_paseto-0.5.2-py3-none-any.whl | Python 3 | none | any | Details for python_paseto-0.5.2-py3-none-any.whl |
Total release size: 24.2 kB
Release files / python-paseto-0.5.2.tar.gz
| Download URL | python-paseto-0.5.2.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a27032ba706e9e0e44dc5af5723579935c5a45c1f1bb991023e0d53f258c4c89
|
|
BLAKE2b-256 checksum How to use checksums |
7d5899e1c46a9f1b442510c488bc9d7782f5a3b5e5f36c0f50595a356a080548
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.9.7 Linux/5.8.0-1042-azure
|
Release files / python_paseto-0.5.2-py3-none-any.whl
| Download URL | python_paseto-0.5.2-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dcf7b4699e7c03c7e1ee7291cd0249a63aad11928a31fb6bd2efe36720d02ff4
|
|
BLAKE2b-256 checksum How to use checksums |
3226959c2689988cb94a6a0c38ce3fb80f94689b0a41975c442e8ee890b12f8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.9.7 Linux/5.8.0-1042-azure
|
Security for python-paseto 0.5.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.