AES-256-GCM 加密解密测试工具

使用密码短语和 PBKDF2 密钥派生,在浏览器中测试 AES-256-GCM。

// about

工具介绍

工具使用 AES-256-GCM 加密,并通过 PBKDF2-SHA-256 派生密钥。适合学习和本地测试,不替代生产环境的密钥管理。

如何使用

  1. 输入要加密的文本或要解密的数据。
  2. 输入相同密码短语,选择加密或解密。
  3. 复制结果,不要在公开工具中重复使用生产密钥。

人们为何使用此工具

  • 无需上传明文即可测试 AES 加密和解密。
  • 可设置密码短语和 PBKDF2 迭代次数。
  • 输出包含此工具解密所需的信息。

常见问题解答 (FAQ)

可以用于生产秘密吗?

不可以。生产数据应使用审核过的加密方案和托管密钥存储。

指南 · 安全 · 约 3 分钟

哈希函数通俗讲解:MD5、SHA-1、SHA-256 的区别与正确用法

下载校验和、Git 提交 ID、区块链地址都是哈希值。本文讲解哈希与加密的区别,以及不同任务该选哪种算法。

哈希函数接收任意长度的输入,输出一个固定长度的短值,称为哈希值或摘要。无论你哈希的是一个单词还是几 GB 的视频,SHA-256 的输出始终是 256 位,即 64 个十六进制字符。

SHA-256("hello")  = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
SHA-256("hello!") = ce06092fb948d9ffac7d1a376e404b26b7575bcc11ee05a4615fef4fec3a308b
MD5("hello")      = 5d41402abc4b2a76b9719d911017c592
好的哈希函数应具备的三个特性、MD5 和 SHA-1 为何不再用于安全场景,以及如何在文件完整性校验和密码存储中正确使用哈希。
阅读指南 →
用 AI 自己做

用 AI 亲手打造这个工具

想要自己的版本?把下面的任务提示词粘贴到 AI 聊天中,或将技能文件保存到 AI 编程助手。其中包含我们开发此工具时整理的功能、边界情况和测试用例。

提示词和技能以英文提供,AI 工具在任何语言环境下都能很好地理解。

AI 任务提示词

直接粘贴到 Claude、ChatGPT、Gemini 等 AI 聊天中即可。

You are an experienced full-stack web developer. Build a web tool called "AES 加密测试工具" that meets the requirements below.

## Goal

Build a tester that encrypts and decrypts text with AES-256-GCM using a password.

## Core features

- Encrypt and decrypt modes
- Derive the key from the password with PBKDF2 and a high iteration count
- Random salt and 12-byte IV for every encryption
- Output salt + IV + ciphertext as one Base64 string
- Copy result

## Inputs

- Plain text or Base64 ciphertext
- Password

## Outputs

- Base64 ciphertext or decrypted plain text
- Summary of algorithm and parameters

## Edge cases and handling rules

- Show 'authentication failed' for a wrong password or tampered ciphertext
- Reject empty passwords
- Explain that the same plain text encrypts differently each time
- Use the Web Crypto API so keys and text never leave the browser

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- Encrypt then decrypt with the same password returns the original
- Changing one character of the ciphertext makes decryption fail
- Encrypting the same input twice gives different output

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

技能 (SKILL.md)

在 Claude Code 等 AI 编程助手中保存为 .claude/skills/build-encryption-tester/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-encryption-tester
description: Use when building or changing a AES 加密测试工具 tool. Build a tester that encrypts and decrypts text with AES-256-GCM using a password.
---

# Build: AES 加密测试工具

## Goal

Build a tester that encrypts and decrypts text with AES-256-GCM using a password.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Encrypt and decrypt modes
- Derive the key from the password with PBKDF2 and a high iteration count
- Random salt and 12-byte IV for every encryption
- Output salt + IV + ciphertext as one Base64 string
- Copy result

## Inputs

- Plain text or Base64 ciphertext
- Password

## Outputs

- Base64 ciphertext or decrypted plain text
- Summary of algorithm and parameters

## Rules

- Show 'authentication failed' for a wrong password or tampered ciphertext
- Reject empty passwords
- Explain that the same plain text encrypts differently each time
- Use the Web Crypto API so keys and text never leave the browser
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] Encrypt then decrypt with the same password returns the original
- [ ] Changing one character of the ciphertext makes decryption fail
- [ ] Encrypting the same input twice gives different output

交给 AI 时的小技巧

  • 在第一行写明技术栈(如 React、Vue 或纯 HTML),生成的代码会更贴合你的项目。
  • 在接受代码前,请让 AI 运行列出的测试用例并展示结果。
  • 不要把真实密码、客户数据或 API 密钥粘贴到提示词中,请用示例值代替。