Skip to main content

CryptPickle

Encrypted python object serialization

python python Downloads Issues Test

CryptPickle allows you to easily encrypt python objects into a file and decrypt, regardless of their content. It may be any python object, including for example a Pandas DataFrame.

Migration from v0.x

Breaking change: CryptPickle 1.0 changes the encryption format from AES-ZIP (pyzipper) to AES-256-GCM with PBKDF2 (cryptography). Files created with versions prior to 1.0 are not readable with this version.

To migrate existing data: decrypt with CryptPickle 0.9, then re-encrypt with CryptPickle 1.0.

Install

pip install cryptpickle

Examples

Usage example 1 (Encrypt and Decrypt a dict with some sensible data):

import cryptpickle

# Create a dictionary with some data
# It could be any other python object. ie: a Pandas Dataframe 
ej1 = { 'name1': 'John Doe',
        'name2': 'Lisa Doe'}

# Print the data
print(ej1)

# Serialice the data in an encrypted file with a password (file.crypt)
cryptpickle.obj_to_encrypted(ej1,password="SecretPassword",path='./file.crypt')

# Load the serialiced data in other python object. Password is needed to unencrypt the data
ej2 =cryptpickle.obj_from_encrypted(password="SecretPassword",path='./file.crypt')

# Print the data
print(ej2)

Usage example 2 (Encrypt and Decrypt a Pandas DataFrame with some sensible data):

import cryptpickle
import pandas as pd

# Create a dictionary with some data
df1 = pd.DataFrame({'A': [1, 2, 3],
                   'B': ['one', 'one', 'four']})

# Print the data
print(df1)

# Serialice the data in an encrypted file (path) with a password (password)
cryptpickle.obj_to_encrypted(df1,password="SecretPassword",path='./pd_data.crypt')

# Load the serialiced data in other Pandas DataFrame.
df2 =cryptpickle.obj_from_encrypted(password="SecretPassword",path='./pd_data.crypt')

# Print the data
print(df2)

Install and try it (Linux)

  1. Clone this repository and enter in the directory:
git clone https://github.com/privtools/CryptPickle.git
cd CryptPickle
  1. Create a vitual environment:
python3 -m venv .venv
  1. Activate the virtual environment:
source .venv/bin/activate
  1. Install the package:
pip install -r requirements.txt
  1. Run sample1:
python sample1.py
  1. Run sample2:
python sample2.py

Metadata

Release files for cryptpickle 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cryptpickle 1.1
File Size Uploaded Provenance Actions
cryptpickle-1.1.tar.gz 8.2 kB Without provenance Details for cryptpickle-1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cryptpickle 1.1
File Interpreter ABI Platform Actions
cryptpickle-1.1-py3-none-any.whl Python 3 none any Details for cryptpickle-1.1-py3-none-any.whl

Total release size: 17.0 kB

Release files / cryptpickle-1.1.tar.gz

Download URL cryptpickle-1.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
242df1ab6855b3534eda0d30b3db695567b0b030ace60c13d7b0fe4685fe728c
BLAKE2b-256 checksum
How to use checksums
238b33f23484b06e98a83fd5520a6966ab99c6cfd02e57eefced39ad43a09adb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / cryptpickle-1.1-py3-none-any.whl

Download URL cryptpickle-1.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9965e0e43bc55d9fa35bb68bcaf920da60ccf19a4fced53d2872fd29142aa262
BLAKE2b-256 checksum
How to use checksums
f3c9c31de234c85fd5dbd134e1046ac9f47622f6a64a7a98484ecd0e7dfba2cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for cryptpickle 1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page