Encrypted python object serialization
Project description
CryptPickle
Encrypted python object serialization
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.
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(df11,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)
- Clone this repository and enter in the directory:
git clone https://github.com/privtools/CryptPickle.git
cd CryptPickle
- Create a vitual environment:
python3 -m venv .venv
- Activate the virtual environment:
source .venv/bin/activate
- Install the package:
pip install -r requirements.txt
- Run sample1:
python sample1.py
- Run sample2:
python sample2.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cryptpickle-0.7.tar.gz.
File metadata
- Download URL: cryptpickle-0.7.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bf2c411c76b685997fcbae865e2e557a9da81ac1c06f42ef0fe36dd40ac5560
|
|
| MD5 |
e54103ecf050328f6a8a2edbce03a858
|
|
| BLAKE2b-256 |
d8e57a6c699c714017164bb2c3b4864894f125900bdaa42846d6c8d8ba98745e
|
File details
Details for the file cryptpickle-0.7-py3-none-any.whl.
File metadata
- Download URL: cryptpickle-0.7-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26a53e6e7ecb364af010652d9ef05a65e07b95bbc37fec3822f34a0437662c20
|
|
| MD5 |
91e0958d848b54778ab42ac9fe6f252f
|
|
| BLAKE2b-256 |
e7ac8c559ac8272b6f76672b1ee273b16a105e18e3628339a4d33d06957a4e21
|