哈希生成器

生成 MD5、SHA-1、SHA-256、SHA-384 和 SHA-512 哈希。

// about

工具介绍

哈希是文本或文件的“数字指纹”。无论输入文字有多长,哈希都会将其转换为固定长度的代码。本工具支持生成 MD5、SHA-1、SHA-256 和 SHA-512 哈希。

如何使用

  1. 在输入框中输入或粘贴要处理的文本。
  2. 选择所需的哈希算法。
  3. 点击“生成”并复制生成的哈希指纹码。

人们为何使用此工具

  • 快速对比验证两段文字或文件内容是否完全一致。
  • 全面支持常用的 SHA-256、MD5 等多种主流哈希算法。
  • 秒级计算出结果,方便对比与核对。

常见问题解答 (FAQ)

能从哈希码还原出原始文字吗?

不能!哈希算法是单向的,无法通过哈希值逆查原始文本。

SHA-256 通常用于哪些场景?

广泛用于网络安全、数字证书和软件下载的完整性校验。

MD5 适合用于密码加密吗?

MD5 适合快速文件比对,如果是密码和安全用途,建议使用 SHA-256。

指南 · 安全 · 约 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 "哈希生成器" that meets the requirements below.

## Goal

Build a tool that computes MD5, SHA-1, SHA-256 and SHA-512 hashes of text in one go.

## Core features

- Show several algorithms at once
- Output as lower/upper-case hex or Base64
- HMAC mode with a secret key
- Compare two hash values
- Copy button for each result

## Inputs

- Text to hash
- Output format and optional HMAC key

## Outputs

- Hash per algorithm
- Comparison result (match/mismatch)

## Edge cases and handling rules

- Hash the empty string correctly
- Explain that CRLF versus LF line endings change the hash
- Keep the UI responsive for large inputs
- Warn that MD5 and SHA-1 are unsuitable for security

## 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)

- SHA-256('hello') = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
- MD5('hello') = 5d41402abc4b2a76b9719d911017c592
- 'Hello' and 'hello' produce different hashes

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-hash-generator/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-hash-generator
description: Use when building or changing a 哈希生成器 tool. Build a tool that computes MD5, SHA-1, SHA-256 and SHA-512 hashes of text in one go.
---

# Build: 哈希生成器

## Goal

Build a tool that computes MD5, SHA-1, SHA-256 and SHA-512 hashes of text in one go.

## 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

- Show several algorithms at once
- Output as lower/upper-case hex or Base64
- HMAC mode with a secret key
- Compare two hash values
- Copy button for each result

## Inputs

- Text to hash
- Output format and optional HMAC key

## Outputs

- Hash per algorithm
- Comparison result (match/mismatch)

## Rules

- Hash the empty string correctly
- Explain that CRLF versus LF line endings change the hash
- Keep the UI responsive for large inputs
- Warn that MD5 and SHA-1 are unsuitable for security
- 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

- [ ] SHA-256('hello') = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
- [ ] MD5('hello') = 5d41402abc4b2a76b9719d911017c592
- [ ] 'Hello' and 'hello' produce different hashes

交给 AI 时的小技巧

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