加密的python对象序列化
项目描述
地穴泡菜
加密的python对象序列化
CryptPickle 允许您轻松地将 python 对象加密到文件中并解密,而不管它们的内容如何。它可以是任何 python 对象,包括例如 Pandas DataFrame。
安装
pip install cryptpickle
例子
使用示例 1(使用一些敏感数据加密和解密 dict):
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)
使用示例 2(使用一些敏感数据加密和解密 Pandas DataFrame):
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)
安装并试用 (Linux)
- 克隆此存储库并进入目录:
git clone https://github.com/privtools/CryptPickle.git
cd CryptPickle
- 创建虚拟环境:
python3 -m venv .venv
- 激活虚拟环境:
source .venv/bin/activate
- 安装包:
pip install -r requirements.txt
- 运行示例 1:
python sample1.py
- 运行示例 2:
python sample2.py
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
cryptpickle-0.9.tar.gz
(8.4 kB
查看哈希)
内置分布
cryptpickle-0.9-py3-none-any.whl
(7.5 kB
查看哈希)
关
cryptpickle -0.9.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | c6affef769c16e3ed40e006c80f301a8c4c9a8483c14eb60fb4ee86f6224cb5e |
|
| MD5 | 8abe8da9f7992a7163eec75ee9fe6f17 |
|
| 布莱克2-256 | 3e824f7a53b58a857d0f7990d502c2670a5807479ac9f3cf20f22d2b78353af1 |
关
cryptpickle -0.9-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | a3ee95547e65455fde45f4875686e3c0a9aabbfb646a19faa69c579c3cb21f44 |
|
| MD5 | ac9c4ebfede0cc2a1bfcb68ed8dc95d1 |
|
| 布莱克2-256 | 13293aa2e8561359b93e9363fbf293b4f3f9ad88ef5238c5d88a7bc4e44a4166 |