Skip to main content

A tool for data encryption and decryption

Project description

Data Crypto

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

功能特点

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

安装

pip install data-crypto-szjh

环境变量配置

在使用前需要配置以下环境变量,可以创建 .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.2.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.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: data_crypto_szjh-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 b1ce86ed0a5e06dc0637ffaf23c81aeaddc2c5700173111e7a016e57ce4baa53
MD5 922955c46df3f5dabe5404a4ded71f68
BLAKE2b-256 5e93003cf0836f23785a52342440b818c3cdecef3881eb9bfda8e70d6c745874

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for data_crypto_szjh-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5939743fe061d903c9c2a4bb0d0bf34e309e10fcb7ae10d6e809d92ab8004c60
MD5 95522b5b0465fa19a86a3b933e9ff0ed
BLAKE2b-256 68c55c031dcb87d2d380f39d208e0fa2dc057591e00024cbb290ab9707e62156

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