Skip to main content

A tool for data encryption and decryption

Project description

Data Crypto

一个用于数据加密和解密的Python工具包,主要用于处理数据库中的敏感信息。

功能特点

  • 支持AES-256-CBC加密/解密
  • 支持批量数据处理
  • 支持数据库连接池
  • 支持导出解密后的数据到Excel
  • 多线程处理提升性能
  • 支持断点续传
  • 支持无效日期处理

安装

pip install data-crypto

环境变量配置

在使用前需要配置以下环境变量,可以创建 .env 文件:

本地数据库配置

local_host=本地数据库地址
local_user=本地数据库用户名
local_password=本地数据库密码
local_database=本地数据库名

远程数据库配置

remote_host=远程数据库地址
remote_user=远程数据库用户名
remote_password=远程数据库密码
remote_database=远程数据库名

加密密钥配置(也可以不配置,系统会随机生成一个)

ENCRYPTION_KEY=your_encryption_key

使用示例

DataEncryptor 类

DataEncryptor 类用于加密数据库中的敏感字段。

参数说明:

  • fields_to_encrypt: 需要加密的字段列表
  • batch_size: 每批处理的记录数(默认1000)
  • table_name: 要处理的表名
  • max_workers: 工作线程数(默认4)
  • queue_size: 队列大小(默认10)
  • checkpoint_file: 断点续传文件路径
  • timeout: 队列等待超时时间(秒)
  • invalid_dates: 需要处理的无效日期列表
from data_crypto import encryptor

encryptor = encryptor.DataEncryptor()
encryptor.run()

DataDecryptor 类

DataDecryptor 类用于解密数据库中的加密字段并导出到Excel文件。

参数说明:

  • fields_to_decrypt: 需要解密的字段列表
  • table_name: 要处理的数据表名
  • batch_size: 每批处理的记录数
  • output_file: 输出的Excel文件名
from data_crypto import decryptor

decryptor = decryptor.DataDecryptor()
decryptor.run()

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

data_crypto_szjh-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

data_crypto_szjh-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file data_crypto_szjh-0.1.0.tar.gz.

File metadata

  • Download URL: data_crypto_szjh-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.7

File hashes

Hashes for data_crypto_szjh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7ec350caa2f51314b918d1ac0d0619666596879a60a8570fe0061b31edf8a698
MD5 cdf4395924e359e1245a60103dac5935
BLAKE2b-256 54d51a74feee614e95af24fb7649218a9f52d198f755e1168a9b95a2f56df31b

See more details on using hashes here.

File details

Details for the file data_crypto_szjh-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for data_crypto_szjh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc582323979c4799e7fc5b9086b9a6b9773a0b695920a402ffc1140beff6cde1
MD5 cd196dcb0ddd0cc3d53c2cc6c0a4aa9f
BLAKE2b-256 7a04eff2433a4c3ee450906377aa08b76b694d6059b254866050313a49e4875e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page