AES 加解密 使用教程
详细使用指南、最佳实践与常见问题解答
使用场景
AES 加解密工具适用于敏感数据传输、配置文件加密、API 密钥保护、数据库字段加密等场景。当你需要在不安全的信道传输文本数据,或本地保存敏感信息时,AES-256 是行业标准的对称加密算法。
Use Cases
The AES tool is useful for sensitive data transmission, config file encryption, API key protection, database field encryption, etc. When you need to transmit text over an insecure channel or store sensitive information locally, AES-256 is the industry-standard symmetric encryption algorithm.
功能特点
- AES-256-GCM:推荐模式,带认证标签,可检测密文篡改
- AES-256-CBC:兼容传统系统,无认证
- 密码派生:用 PBKDF2 算法(10 万次迭代 + SHA-256)从密码派生 256 位密钥
- Hex 密钥:支持直接输入 64 位 hex 密钥,适合专业用户
- Web Crypto API:使用浏览器原生加密,密钥永不离开浏览器
- UTF-8 安全:正确处理中文等非 ASCII 字符
Features
- AES-256-GCM: recommended mode with authentication tag, tamper-detecting
- AES-256-CBC: legacy compatibility, no authentication
- Password-derived: 256-bit key derived via PBKDF2 (100,000 iterations + SHA-256)
- Hex key: accept direct 64-char hex input for advanced users
- Web Crypto API: native browser encryption, key never leaves the browser
- UTF-8 safe: correctly handles non-ASCII characters like Chinese
使用示例
示例 1:场景一:加密 API 密钥保存到笔记 — 输入密钥、设置密码、选 GCM、点加密,把 base64 密文存到笔记,需要时再粘贴回来解密。
示例 2:场景二:发送私密消息给同事 — 用约定好的密码加密消息,通过微信/邮件发送密文,对方用同样密码解密。
示例 3:场景三:兼容旧系统 — 对方系统只支持 CBC,选 CBC 模式加密,把 hex 密钥通过其他安全渠道告知对方。
Examples
Example 1: Scenario 1: Encrypt an API key for note storage — input the key, set a password, choose GCM, click Encrypt, save the base64 ciphertext; decrypt later when needed.
Example 2: Scenario 2: Send a private message to a colleague — encrypt with a shared password, send the ciphertext via chat/email, the recipient decrypts with the same password.
Example 3: Scenario 3: Legacy system compat — the other system only supports CBC; choose CBC mode, share the hex key via another secure channel.
最佳实践
- 优先使用 GCM 模式,带认证可防篡改
- 密码至少 12 位,包含大小写字母、数字、符号
- PBKDF2 迭代次数越高越安全(本工具为 10 万次)
- 密文传输时配合 HTTPS,防止中间人攻击
- hex 密钥需通过安全渠道(如线下、密码管理器)分享,不要明文传输
Best Practices
- Prefer GCM mode — authenticated, tamper-resistant
- Password at least 12 chars with mixed case, digits, symbols
- Higher PBKDF2 iterations = more secure (this tool uses 100,000)
- Always pair ciphertext with HTTPS to prevent MITM attacks
- Share hex keys only via secure channels (offline, password manager) — never in plaintext
常见问题
我的密码会被上传吗?
不会。所有加解密都在你的浏览器本地完成,密码和密钥永不离开你的设备。
GCM 和 CBC 怎么选?
GCM 是推荐模式,带认证标签,可检测密文是否被篡改。CBC 仅用于兼容旧系统,无认证,更容易被攻击。
密文格式是什么?
密码模式:base64(salt[16 字节] + iv + ciphertext)。Hex 模式:base64(iv + ciphertext)。
解密失败怎么办?
检查:1) 密码/密钥是否正确 2) 模式是否与加密时一致 3) 密文是否完整复制 4) 是否选错密钥来源(密码/hex)。
FAQ
Will my password be uploaded?
No. All encryption/decryption is done locally in your browser; password and key never leave your device.
How to choose between GCM and CBC?
GCM is recommended — it has an authentication tag to detect tampering. CBC is only for legacy systems; no authentication, more vulnerable.
What is the ciphertext format?
Password mode: base64(salt[16 bytes] + iv + ciphertext). Hex mode: base64(iv + ciphertext).
What if decryption fails?
Check: 1) correct password/key 2) mode matches encryption 3) full ciphertext copied 4) correct key source (password/hex) selected.