Skip to main content

A comprehensive encryption tool supporting multiple algorithms

Project description

加密工具 (CryptoTool)

这是一个基于Python的加密工具,提供了多种加密算法的实现,包括AES对称加密、RSA非对称加密以及混合加密方案。

功能特点

  • AES对称加密/解密
  • RSA非对称加密/解密
  • 混合加密方案(AES + RSA)
  • 文件加密/解密支持
  • 完整的错误处理和日志记录
  • 支持命令行操作

安装

通过PyPI安装(推荐)

pip install huawuque-cryptool

从源码安装

  1. 克隆项目到本地:
git clone https://github.com/huawuque/cryptool.git
cd cryptool
  1. 创建并激活虚拟环境:
python -m venv venv
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows
  1. 安装依赖:
pip install -r requirements.txt

使用方法

命令行使用

安装后,您可以通过cryptool命令在命令行中使用该工具:

# 查看帮助
cryptool --help

# 运行示例演示
cryptool example

# AES加密
cryptool aes-encrypt "要加密的文本"

# AES解密
cryptool aes-decrypt "加密后的文本"

# RSA加密
cryptool rsa-encrypt "要加密的文本"

# RSA解密
cryptool rsa-decrypt "加密后的文本"

# 混合加密(结果保存到文件)
cryptool hybrid-encrypt "要加密的文本"

# 混合解密(从文件读取)
cryptool hybrid-decrypt hybrid_encrypted.json

# Base64编码
cryptool base64-encode "要编码的文本"

# Base64解码
cryptool base64-decode "编码后的文本"

Python代码中使用

from cryptool.core.app import CryptoApp

# 初始化加密工具
app = CryptoApp()

# AES加密示例
text = "这是一个测试文本"
encrypted_aes = app.encrypt_aes(text)
print(f"AES加密后: {encrypted_aes}")
decrypted_aes = app.decrypt_aes(encrypted_aes)
print(f"AES解密后: {decrypted_aes}")

# RSA加密示例
encrypted_rsa = app.encrypt_rsa(text)
print(f"RSA加密后: {encrypted_rsa}")
decrypted_rsa = app.decrypt_rsa(encrypted_rsa)
print(f"RSA解密后: {decrypted_rsa}")

# 混合加密示例
encrypted_hybrid = app.encrypt_hybrid(text)
print(f"混合加密后: {encrypted_hybrid}")
decrypted_hybrid = app.decrypt_hybrid(encrypted_hybrid)
print(f"混合解密后: {decrypted_hybrid}")

# Base64编码示例
encoded = app.encode_base64(text)
print(f"Base64编码后: {encoded}")
decoded = app.decode_base64(encoded)
print(f"Base64解码后: {decoded}")

配置

项目使用.env文件进行配置,主要配置项包括:

  • AES_KEY_LENGTH: AES密钥长度(默认32字节)
  • RSA_KEY_SIZE: RSA密钥大小(默认2048位)
  • LOG_LEVEL: 日志级别(默认INFO)

注意事项

  • 本工具生成的RSA密钥对存储在内存中,每次运行时会生成新的密钥对
  • 日志文件默认保存在logs目录下
  • 混合加密结果通常保存为JSON格式

许可证

MIT License

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

huawuque_cryptool-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

huawuque_cryptool-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: huawuque_cryptool-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for huawuque_cryptool-0.1.1.tar.gz
Algorithm Hash digest
SHA256 47d9d7b0149c4c6acfbbf3e20abf0546e8ea9876c62eee899d2eb6dc8c7e9c82
MD5 1a7ff63f039219fcd43e5b4dbb4691b0
BLAKE2b-256 3b31670d7e1c35c91acd0b221ebf9e1a4740cadc5f9ce5d02fdffcff9a0d93b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for huawuque_cryptool-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5a358a5e6e1bee7c94e7cc7af626cab85e903bc90509c2f54e1c15531d0462c1
MD5 57c869f32a4bee2e4dccb73c9bb3d850
BLAKE2b-256 8db2c52af2b9cd46060a124df28789dece8d414421729aea204f8d785ce0835c

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