RakkaEvandra06/QuanSphere
GitHub: RakkaEvandra06/QuanSphere
一款基于 Python 的生产级命令行加密工具包,提供对称加密、非对称加密、混合加密、数字签名、哈希、密钥派生和文件保护等全套密码学功能。
Stars: 0 | Forks: 0
[](https://www.python.org/)
[](https://github.com/RakkaEvandra06/QuanSphere/releases)
[](LICENSE.txt)
[](https://github.com/RakkaEvandra06/QuanSphere)
[](https://github.com/RakkaEvandra06/QuanSphere)
[](https://github.com/RakkaEvandra06/QuanSphere)
[](https://github.com/RakkaEvandra06/QuanSphere)
[](https://github.com/RakkaEvandra06/QuanSphere)
# QuanSphere — 强化加密工具包
**ZeroTrace** 是一个生产级、强化的加密工具包和 CLI,专为在 Python 中进行安全数据操作而设计。它涵盖了日常加密需求的方方面面:对称和非对称加密、混合密钥交换、数字签名、多算法哈希、基于密码的加密、分块文件加密以及加密安全的随机数生成——所有这些都通过一个统一的 `crypto-toolkit` 命令来完成。
## 目录
- [关于本项目](#about-the-project)
- [架构](#architecture)
- [安装](#installation)
- [验证安装](#verify-installation)
- [用法](#usage)
- [开发](#development)
- [贡献](#contributing)
- [许可证](#license)
- [免责声明](#disclaimer)
## 💡 关于本项目
QuanSphere 的设计围绕着这样一个原则:**正确的密码学应该是最容易、最自然的路径**。工具包中的每一个决策都体现了这一点:
- **深度防御封装格式** 每个 ciphertext token 都包含一个带版本的 magic header、算法标签、nonce 和 GCM 身份验证标签。在任何明文字节被释放之前,就能检测到篡改行为。
- **混合加密** ECC (SECP256R1 / ECDH) 和 X25519 混合路径将临时的 Diffie-Hellman 与 AES-256-GCM 和 HKDF-SHA-256 结合在一起,因此接收者的长期私钥永远不会被用来直接加密数据。
- **默认使用 Argon2id** 基于密码的加密和文件加密开箱即用地使用 Argon2id(时间成本 3,内存 64 MiB,并行度 4)来派生密钥。PBKDF2-HMAC 可作为备选方案,其迭代次数符合 OWASP 2023 标准。
- **解密时的 DoS 防护** 所有 PBE 和文件加密路径都会限制从不受信任的信封中读取的 KDF 参数,防止攻击者触发过度的 CPU 或内存使用。
- **密钥材料清零** 共享密钥和派生密钥在使用后会立即使用 `ctypes.memset` (CPython) 进行覆盖。
- **无明文泄漏** 原始密码和敏感参数永远不会被记录、打印或存储。当密码出现在 shell 历史记录中时,CLI 标志会发出明显的警告,并始终推荐使用 `--prompt-password`。
- **分块文件流式传输** 任意大小的文件都会被分成 64 KiB 的块进行加密,每个块的 AAD 会将该块与其位置和文件头绑定,从而检测出 bit-flip 攻击和截断攻击。
## 🏗️ 架构
```
QuanSphere/
├── assets/ # Banner images and static assets
├── crypto_toolkit/
│ ├── cli/
│ │ ├── __init__.py # CLI package version
│ │ ├── main.py # Typer app all CLI commands
│ │ └── output.py # Rich-powered terminal output helpers
│ └── core/
│ ├── asymmetric.py # RSA-4096, ECC P-256, X25519 keygen, OAEP, hybrid ECDH
│ ├── constants.py # Shared algorithm parameters and envelope magic bytes
│ ├── exceptions.py # Typed exception hierarchy (8 exception classes)
│ ├── file_crypto.py # Chunked AES-256-GCM file encryption/decryption
│ ├── hashing.py # SHA-256/512, SHA3-256/512, BLAKE2b/s data, stream, file
│ ├── kdf.py # Argon2id and PBKDF2-HMAC key derivation
│ ├── pbe.py # Password-based encryption (Argon2id or PBKDF2 + AES-GCM)
│ ├── random_gen.py # Cryptographically secure key, token, and password generation
│ ├── signatures.py # Ed25519 and RSA-PSS sign/verify + PEM serialisation
│ └── symmetric.py # AES-256-GCM and ChaCha20-Poly1305 authenticated encryption
├── tests/
│ ├── integration/
│ │ ├── __init__.py
│ │ └── test_cli.py # End-to-end CLI integration tests
│ └── unit/
│ ├── __init__.py
│ ├── conftest.py # Shared fixtures
│ ├── test_asymmetric.py
│ ├── test_file_crypto.py
│ ├── test_hashing.py
│ ├── test_kdf.py
│ ├── test_pbe.py
│ ├── test_random_gen.py
│ ├── test_signatures.py
│ └── test_symmetric.py
├── LICENSE.txt
├── pyproject.toml
└── README.md
```
## ⚙️ 安装
**要求:** Python ≥ 3.10
```
# 1. Clone 仓库
git clone https://github.com/RakkaEvandra06/QuanSphere.git
cd QuanSphere
# 2. 创建并激活虚拟环境(推荐)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. 安装所有开发依赖
pip install -e ".[dev]"
```
**仅安装运行时(不包含开发工具):**
```
pip install -e .
```
### 验证安装
```
crypto-toolkit --help
```
## 🚀 用法
### 对称加密
```
# 生成 256 位 AES 密钥
crypto-toolkit generate-key --type symmetric
# → Symmetric Key (hex): a1b2c3...
# 使用密钥加密 (AES-256-GCM)
crypto-toolkit encrypt "my secret message" --key
标签:CVE, Python, 加密, 密码学, 手动系统调用, 数字签名, 文件保护, 无后门, 漏洞扫描器, 逆向工具