Skip to content

Commit 60b90d4

Browse files
author
爱音爱素食
committed
加密/解密软件基本完成
0 parents  commit 60b90d4

File tree

11 files changed

+1012
-0
lines changed

11 files changed

+1012
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Virtual Environment
2+
.venv/
3+
venv/
4+
env/

.idea/Encrypt.iml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Python Encryption Tool (PBKDF2 + AES)
2+
3+
This is a GUI-based encryption tool built with Python and Tkinter. It uses AES (CBC mode) for encryption and PBKDF2 for key derivation, ensuring high security for both text and files.
4+
5+
## Features
6+
7+
- **Language Support**: Switch between English and Chinese (中文) instantly.
8+
- **Text Encryption/Decryption**: Securely encrypt messages with a custom signature (password).
9+
- **File Encryption/Decryption**: Support for large files with progress tracking.
10+
- **Drag & Drop**: Easily drag files into the application (requires `tkinterdnd2`).
11+
- **Security**:
12+
- AES-256 (default), AES-192, AES-128 support.
13+
- PBKDF2-HMAC-SHA256 with 10,000 iterations for key derivation.
14+
- Random Salt and IV generated for every operation.
15+
- PKCS7 Padding.
16+
17+
## Requirements
18+
19+
- Python 3.8+
20+
- Dependencies listed in `requirements.txt`:
21+
- `cryptography`
22+
- `tkinterdnd2` (optional, for drag-and-drop support)
23+
24+
## Installation
25+
26+
1. Clone or download this repository.
27+
2. Install dependencies:
28+
```bash
29+
pip install -r requirements.txt
30+
```
31+
*Note: If `tkinterdnd2` fails to install, the application will still work but without drag-and-drop functionality.*
32+
33+
## Usage
34+
35+
Run the application:
36+
```bash
37+
python main.py
38+
```
39+
40+
### 1. Control Panel (Top)
41+
- **Signature**: Enter your password/passphrase here. This is used to derive the encryption key.
42+
- **Confirm Sign**: Optional visual confirmation to lock in your intent.
43+
- **Algorithm**: Choose between AES-128, AES-192, or AES-256 (default).
44+
- **Language**: Toggle between English and Chinese interface.
45+
- **Set Output Dir**: Choose where encrypted/decrypted files should be saved by default.
46+
47+
### 2. Text Encryption (Left)
48+
- Enter text in the bottom box.
49+
- Click **Encrypt**.
50+
- The result (Base64 encoded) appears in the top history log.
51+
52+
### 3. Text Decryption (Middle)
53+
- Paste the Base64 encrypted string into the bottom box.
54+
- Ensure the **Signature** matches the one used for encryption.
55+
- Click **Decrypt**.
56+
- The original text appears in the top history log.
57+
58+
### 4. File Operations (Right)
59+
- **Encrypt File**:
60+
- Drag a file into the top box OR click "Select File".
61+
- Click **Encrypt File**.
62+
- The file will be saved with a `.enc` extension in the selected output directory (or same folder).
63+
- **Decrypt File**:
64+
- Drag an encrypted file (`.enc`) into the bottom box.
65+
- Click **Decrypt File**.
66+
- The file will be decrypted with a `.dec` extension.
67+
68+
## Technical Details
69+
70+
- **Key Derivation**:
71+
- Function: `PBKDF2HMAC(SHA256)`
72+
- Iterations: 10,000
73+
- Salt: 16 bytes (Randomly generated per encryption, stored in output)
74+
- **Encryption**:
75+
- Algorithm: AES (CBC Mode)
76+
- IV: 16 bytes (Randomly generated per encryption, stored in output)
77+
- Padding: PKCS7 (128-bit block size)
78+
- **File Format**:
79+
- `[Salt (16 bytes)] [IV (16 bytes)] [Encrypted Data ...]`
80+
81+
## Testing
82+
83+
A sample test script `verify_and_generate_samples.py` is included to verify the cryptographic logic without the GUI.
84+
A sample file `test_sample.txt` and its encrypted version `test_sample.txt.enc` are provided.
85+
The password for the sample is: `TestSig123`

README_CN.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Python 加密工具 (PBKDF2 + AES)
2+
3+
这是一个基于 Python 和 Tkinter 构建的图形界面加密工具。它使用 AES(CBC 模式)进行加密,使用 PBKDF2 进行密钥派生,为文本和文件提供高级别的安全性。
4+
5+
## 功能特点
6+
7+
- **语言支持**:可在英语和中文之间即时切换。
8+
- **文本加密/解密**:使用自定义签名(密码)安全地加密消息。
9+
- **文件加密/解密**:支持大文件处理,并带有进度跟踪。
10+
- **拖放功能**:轻松将文件拖入应用程序(需要 `tkinterdnd2`)。
11+
- **安全性**
12+
- 支持 AES-256(默认)、AES-192、AES-128。
13+
- 使用 PBKDF2-HMAC-SHA256 进行密钥派生,迭代次数为 10,000 次。
14+
- 每次操作都生成随机的 Salt 和 IV。
15+
- PKCS7 填充。
16+
17+
## 要求
18+
19+
- Python 3.8+
20+
- 依赖包在 `requirements.txt` 中列出:
21+
- `cryptography`
22+
- `tkinterdnd2`(可选,用于拖放支持)
23+
24+
## 安装
25+
26+
1. 克隆或下载此仓库。
27+
28+
2. 安装依赖:
29+
30+
bash
31+
32+
```
33+
pip install -r requirements.txt
34+
```
35+
36+
*注意:如果 `tkinterdnd2` 安装失败,应用程序仍可运行,但无法使用拖放功能。*
37+
38+
## 使用方法
39+
40+
运行应用程序:
41+
42+
bash
43+
44+
```
45+
python main.py
46+
```
47+
48+
### 1. 控制面板(顶部)
49+
50+
- **签名**:在此处输入你的密码/口令。用于派生加密密钥。
51+
- **确认签名**:可选的可视化确认,用于锁定你的意图。
52+
- **算法**:选择 AES-128、AES-192 或 AES-256(默认)。
53+
- **语言**:在英语和中文界面之间切换。
54+
- **设置输出目录**:选择加密/解密文件的默认保存位置。
55+
56+
### 2. 文本加密(左侧)
57+
58+
- 在底部文本框中输入文本。
59+
- 点击 **加密**
60+
- 结果(Base64 编码)将显示在顶部的历史记录日志中。
61+
62+
### 3. 文本解密(中间)
63+
64+
- 将 Base64 编码的加密字符串粘贴到底部文本框中。
65+
- 确保 **签名** 与加密时使用的签名一致。
66+
- 点击 **解密**
67+
- 原始文本将显示在顶部的历史记录日志中。
68+
69+
### 4. 文件操作(右侧)
70+
71+
- **加密文件**
72+
- 将文件拖入顶部文本框或点击“选择文件”。
73+
- 点击 **加密文件**
74+
- 文件将以 `.enc` 扩展名保存在选定的输出目录(或同一文件夹)中。
75+
- **解密文件**
76+
- 将加密文件(`.enc`)拖入底部文本框。
77+
- 点击 **解密文件**
78+
- 文件将被解密,并以 `.dec` 扩展名保存。
79+
80+
## 技术细节
81+
82+
- **密钥派生**
83+
- 函数:`PBKDF2HMAC(SHA256)`
84+
- 迭代次数:10,000
85+
- Salt:16 字节(每次加密随机生成,存储在输出中)
86+
- **加密**
87+
- 算法:AES(CBC 模式)
88+
- IV:16 字节(每次加密随机生成,存储在输出中)
89+
- 填充:PKCS7(128 位块大小)
90+
- **文件格式**
91+
- `[Salt (16 字节)] [IV (16 字节)] [加密数据 ...]`
92+
93+
## 测试
94+
95+
包含一个示例测试脚本 `verify_and_generate_samples.py`,用于在没有 GUI 的情况下验证加密逻辑。
96+
提供了示例文件 `test_sample.txt` 及其加密版本 `test_sample.txt.enc`
97+
示例文件的密码为:`TestSig123`
98+
99+
## 参考文档
100+
101+
[(1 封私信) 什么是AES加密?详解AES加密算法原理流程 - 知乎](https://zhuanlan.zhihu.com/p/562256846)
102+
103+
[(1 封私信) 深入浅出:Base64编码原理详解 - 知乎](https://zhuanlan.zhihu.com/p/696546724)

0 commit comments

Comments
 (0)