密码生成器

按自定义长度和选项生成安全的随机密码。

// about

工具介绍

生成黑客无法轻易破解的高强度复杂密码,保护您的在线账号安全。您可以自定义密码长度并灵活组合数字、字母和特殊符号。

如何使用

  1. 选择您希望的密码长度(建议 12 位以上)。
  2. 勾选大写字母、小写字母、数字或符号。
  3. 点击“生成”并复制您的新密码。

人们为何使用此工具

  • 一秒快速生成超高安全强度的随机密码。
  • 可随心定制密码长度与包含的字符种类。
  • 所有密码均在本地生成,绝不上传网络,绝对安全。

常见问题解答 (FAQ)

什么样的密码才是安全的?

长度在 12 位以上,且混合了大小写字母、数字和符号的密码最安全。

生成的密码会被保存在网站上吗?

绝不会!密码全过程仅在您的浏览器中计算生成,无人可查。

应该多久更换一次密码?

建议重要账号每隔几个月更换一次密码,且切勿重复使用相同密码。

指南 · 安全 · 约 3 分钟

如何设置强密码:长度、熵与密码管理器

“至少包含一个特殊字符”这类规则大家都很熟悉,但真正让密码变强的是随机性和长度。算一算就能清楚看出为什么有些密码很弱。

攻击者主要使用三种方法:撞库,即用从其他网站泄露的用户名和密码去尝试登录;字典攻击,即尝试常见密码和单词;以及暴力破解,即尝试所有组合。

6 位数字              : 6 × log2(10)  ≈ 20 比特
16 个随机小写字母     : 16 × log2(26) ≈ 75 比特
从 94 种中随机选 12 个 : 12 × log2(94) ≈ 79 比特
16 个随机字母和数字   : 16 × log2(62) ≈ 95 比特
如何计算密码熵、为什么长度比复杂度规则更有效、应避免哪些模式,以及如何使用密码管理器。
阅读指南 →
用 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 random password generator that uses a cryptographically secure random source.

## Core features

- Length from 8 to 128
- Toggle upper case, lower case, digits and symbols
- Option to exclude look-alike characters (0/O, l/1)
- Generate several at once
- Show entropy in bits and a strength label

## Inputs

- Length, character sets, count, exclusions

## Outputs

- List of passwords
- Estimated entropy in bits

## Edge cases and handling rules

- Explain that at least one character set is required
- Guarantee at least one character from each selected set
- Use crypto.getRandomValues, never Math.random
- Avoid modulo bias when picking characters

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

- Every result has 16 characters when length is 16
- Only digits appear when only digits are selected
- 12 characters from 94 shows about 79 bits

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

---
name: build-password-generator
description: Use when building or changing a 密码生成器 tool. Build a random password generator that uses a cryptographically secure random source.
---

# Build: 密码生成器

## Goal

Build a random password generator that uses a cryptographically secure random source.

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

- Length from 8 to 128
- Toggle upper case, lower case, digits and symbols
- Option to exclude look-alike characters (0/O, l/1)
- Generate several at once
- Show entropy in bits and a strength label

## Inputs

- Length, character sets, count, exclusions

## Outputs

- List of passwords
- Estimated entropy in bits

## Rules

- Explain that at least one character set is required
- Guarantee at least one character from each selected set
- Use crypto.getRandomValues, never Math.random
- Avoid modulo bias when picking characters
- 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

- [ ] Every result has 16 characters when length is 16
- [ ] Only digits appear when only digits are selected
- [ ] 12 characters from 94 shows about 79 bits

交给 AI 时的小技巧

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