pylotte
Secure Pickle Serialization with RSA Signatures
pylotte is a lightweight Python utility that allows you to securely serialize Python objects with RSA digital signatures. It ensures the integrity and authenticity of your data by cryptographically signing serialized files and verifying them before loading.
✨ Features
- 🔐 Sign serialized files using an RSA private key
- ✅ Verify signatures with the corresponding public key
- 🛡️ Prevents tampering and ensures data authenticity
- 📦 Simple and minimal interface
- 🔄 Pluggable serializer: use
pickle,dill,cloudpickle, or anydump/loadAPI
📦 Installation
Install directly from PyPI:
# Basic installation with pickle support
pip install pylotte
# With dill support for advanced serialization
pip install pylotte[dill]
🛠 Usage
Basic Usage with Pickle
from pylotte.signed_pickle import SignedPickle
# Initialize with RSA key paths
signer = SignedPickle(public_key_path="public.pem", private_key_path="private.pem")
# Data to serialize
data = {"user": "alice", "role": "admin"}
# Securely dump and sign the pickle file
signer.dump_and_sign(data, "data.pkl", "data.sig")
# Load and verify the signed pickle file
loader = SignedPickle(public_key_path="public.pem")
data_loaded = loader.safe_load("data.pkl", "data.sig")
Advanced Usage with a Custom Serializer
from pylotte.signed_pickle import SignedPickle
import cloudpickle # or dill, or any module with dump/load
signer = SignedPickle(
public_key_path="public.pem",
private_key_path="private.pem",
serializer=cloudpickle,
)
data = {
"name": "bob",
"process": lambda x: x * 2,
"nested": {"func": lambda y: y + 1},
}
signer.dump_and_sign(data, "data.pkl", "data.sig")
loader = SignedPickle(public_key_path="public.pem", serializer=cloudpickle)
data_loaded = loader.safe_load("data.pkl", "data.sig")
result = data_loaded["process"](5) # Returns 10
Using a Custom Serializer (e.g., cloudpickle)
from pylotte.signed_pickle import SignedPickle
import cloudpickle
# Pass any object that provides dump/load
signer = SignedPickle(
public_key_path="public.pem",
private_key_path="private.pem",
serializer=cloudpickle,
)
data = {"callable": lambda x: x + 3}
signer.dump_and_sign(data, "data.pkl", "data.sig")
loader = SignedPickle(public_key_path="public.pem", serializer=cloudpickle)
loaded = loader.safe_load("data.pkl", "data.sig")
🔐 How It Works
-
dump_and_sign():- Serializes your data using the provided serializer (defaults to pickle) and saves it to a file.
- Signs the file contents using an RSA private key.
- Stores the signature in a separate
.sigfile.
-
safe_load():- Reads the serialized file and its signature.
- Verifies the signature using the RSA public key.
- If valid, loads and returns the original data.
🔧 Requirements
- Python 3.9+
cryptography
📄 License
This project is licensed under the MIT License.
🌐 Links
- 📚 Documentation: GitHub Repository
- 🐛 Issue Tracker: Report Bugs
- 📦 PyPI: pylotte on PyPI
👤 Author
Developed by Alpamayo Solutions
Metadata
Release files for pylotte 0.3
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 |
|---|---|---|---|---|
| pylotte-0.3.tar.gz | 11.4 kB | Without provenance | Details for pylotte-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylotte-0.3-py3-none-any.whl | Python 3 | none | any | Details for pylotte-0.3-py3-none-any.whl |
Total release size: 16.6 kB
Release files / pylotte-0.3.tar.gz
| Download URL | pylotte-0.3.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f123fdd23cd7df0845a1df43e6a92357d3d070c08d619b69651b532f18f8beb1
|
|
BLAKE2b-256 checksum How to use checksums |
3b2d1de404f980c9089a804cd075ffac16a39c1a68ea0f1d8f3a16a788d637c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / pylotte-0.3-py3-none-any.whl
| Download URL | pylotte-0.3-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5884bf2b9846eb87e646ae35233587e32c1cc8513a90d54702f427469e2392fa
|
|
BLAKE2b-256 checksum How to use checksums |
628049ceb6b362fecab0027e160040d6e551504f5ceab6191a19cc85bae3ad8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for pylotte 0.3
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.