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.1.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.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: data_crypto_szjh-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 9b0838b6b5b0269b7b76cad4c0e2d31ae5f9afa89987899965d2cb1b8c671679
MD5 6d4dc84e2bc219ba3436544bdadb397c
BLAKE2b-256 eb43a3789635c38d3a7214544faa27368781464be6f84de9bdc8db5df3f5f066

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for data_crypto_szjh-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 253df11647f78954c3f193460c58e7d2db275786a59fdf9f0e8302532857d14d
MD5 a16e8313a8636e70e316ef319a92b3f4
BLAKE2b-256 6829d6b3949a761c95ef287e47e72b7ed9b4a43e7c643309897b3348018eff99

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