A comprehensive encryption tool supporting multiple algorithms
Project description
加密工具 (CryptoTool)
这是一个基于Python的加密工具,提供了多种加密算法的实现,包括AES对称加密、RSA非对称加密以及混合加密方案。
功能特点
- AES对称加密/解密
- RSA非对称加密/解密
- 混合加密方案(AES + RSA)
- 文件加密/解密支持
- 完整的错误处理和日志记录
- 支持命令行操作
安装
通过PyPI安装(推荐)
pip install huawuque-cryptool
从源码安装
- 克隆项目到本地:
git clone https://github.com/huawuque/cryptool.git
cd cryptool
- 创建并激活虚拟环境:
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
- 安装依赖:
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
Release history Release notifications | RSS feed
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.3.tar.gz
(30.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file huawuque_cryptool-0.1.3.tar.gz.
File metadata
- Download URL: huawuque_cryptool-0.1.3.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb7b0801dd3e87214d1385a77a3e16315007f95999250ed2dc8b1c6033ed591b
|
|
| MD5 |
fd121dceb88f52cd21242849b2e3af27
|
|
| BLAKE2b-256 |
1a9173dbfceb542b47b182b45aeaa62b5ae4e5e5c1585a846e01732b92ac9a32
|
File details
Details for the file huawuque_cryptool-0.1.3-py3-none-any.whl.
File metadata
- Download URL: huawuque_cryptool-0.1.3-py3-none-any.whl
- Upload date:
- Size: 34.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00009f371664a156299b9a135fd9287e1c3414f3dcc6ec1d8c3aeb1b7140e1ef
|
|
| MD5 |
20359f6fa78fa258af01cabd50751991
|
|
| BLAKE2b-256 |
f855773cb6d973a1691410b8b6e9a47515766ef1254a79c33bab3f4bac384a23
|