password-gen
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePassword Generation Skill
密码生成技能
Generate secure passwords and secrets.
生成安全密码与密钥。
When to Use
适用场景
- Generate secure passwords
- Create API keys or tokens
- Generate random strings
- Create secure filenames
- Generate cryptographic nonces
- 生成安全密码
- 创建API密钥或令牌
- 生成随机字符串
- 创建安全文件名
- 生成加密nonce
Password Generation
密码生成
Basic Password
基础密码
bash
undefinedbash
undefinedRandom 16 char password
Random 16 char password
openssl rand -base64 16
openssl rand -base64 16
Random 20 char alphanumeric
Random 20 char alphanumeric
openssl rand -hex 20
openssl rand -hex 20
Using /dev/urandom
Using /dev/urandom
tr -dc 'A-Za-z0-9' </dev/urandom | head -c 20
tr -dc 'A-Za-z0-9' </dev/urandom | head -c 20
Using pwgen (if installed)
Using pwgen (if installed)
pwgen 16 1
undefinedpwgen 16 1
undefinedSecure Password with Special Chars
含特殊字符的安全密码
bash
undefinedbash
undefinedInclude special characters
Include special characters
tr -dc 'A-Za-z0-9!@#$%^&*' </dev/urandom | head -c 20
tr -dc 'A-Za-z0-9!@#$%^&*' </dev/urandom | head -c 20
More secure version
More secure version
openssl rand -base64 32 | tr -dc 'A-Za-z0-9!@#$%^&*' | head -c 24
undefinedopenssl rand -base64 32 | tr -dc 'A-Za-z0-9!@#$%^&*' | head -c 24
undefinedMemorable Passwords
易记密码
bash
undefinedbash
undefinedDiceware-style (using wordlist)
Diceware-style (using wordlist)
shuf -n 4 /usr/share/dict/words | tr '\n' '-'
shuf -n 4 /usr/share/dict/words | tr '\n' '-'
Using apg (if installed)
Using apg (if installed)
apg -a 1 -M Ncl
undefinedapg -a 1 -M Ncl
undefinedAPI Keys & Tokens
API密钥与令牌
UUID Generation
UUID生成
bash
undefinedbash
undefinedUUID v4
UUID v4
uuidgen
uuidgen
Or using Python
Or using Python
python3 -c "import uuid; print(uuid.uuid4())"
python3 -c "import uuid; print(uuid.uuid4())"
Or using node
Or using node
node -e "console.log(require('crypto').randomUUID())"
undefinednode -e "console.log(require('crypto').randomUUID())"
undefinedJWT-Style Tokens
JWT风格令牌
bash
undefinedbash
undefinedRandom token (base64)
Random token (base64)
openssl rand -base64 32
openssl rand -base64 32
Hex token
Hex token
openssl rand -hex 32
undefinedopenssl rand -hex 32
undefinedOAuth Secrets
OAuth密钥
bash
undefinedbash
undefinedClient secret
Client secret
openssl rand -base64 32
openssl rand -base64 32
256-bit key
256-bit key
openssl rand -hex 32
undefinedopenssl rand -hex 32
undefinedCryptographic Functions
加密函数
Hash Password
密码哈希
bash
undefinedbash
undefinedSHA-256 hash
SHA-256 hash
echo -n "password" | openssl dgst -sha256
echo -n "password" | openssl dgst -sha256
SHA-512 hash
SHA-512 hash
echo -n "password" | openssl dgst -sha512
echo -n "password" | openssl dgst -sha512
Bcrypt (using htpasswd)
Bcrypt (using htpasswd)
htpasswd -nbBC 10 user password
undefinedhtpasswd -nbBC 10 user password
undefinedGenerate Salt
生成盐值
bash
undefinedbash
undefinedRandom salt (16 bytes hex)
Random salt (16 bytes hex)
openssl rand -hex 16
openssl rand -hex 16
Random salt (16 bytes base64)
Random salt (16 bytes base64)
openssl rand -base64 16
undefinedopenssl rand -base64 16
undefinedScript Examples
脚本示例
Generate Password Script
密码生成脚本
bash
#!/bin/bashbash
#!/bin/bashGenerate a secure password
Generate a secure password
LENGTH="${1:-16}"
CHARS="${2:-A-Za-z0-9!@#$%^&*}"
openssl rand -base64 "$LENGTH" | tr -dc "$CHARS" | head -c "$LENGTH"
echo
undefinedLENGTH="${1:-16}"
CHARS="${2:-A-Za-z0-9!@#$%^&*}"
openssl rand -base64 "$LENGTH" | tr -dc "$CHARS" | head -c "$LENGTH"
echo
undefinedGenerate API Key
API密钥生成脚本
bash
#!/bin/bashbash
#!/bin/bashGenerate API key (prefix_key format)
Generate API key (prefix_key format)
PREFIX="${1:-sk}"
openssl rand -hex 32 | sed "s/^/${PREFIX}_/"
undefinedPREFIX="${1:-sk}"
openssl rand -hex 32 | sed "s/^/${PREFIX}_/"
undefinedGenerate All Keys
全类型密钥生成脚本
bash
#!/bin/bashbash
#!/bin/bashGenerate full set of API credentials
Generate full set of API credentials
echo "=== API Credentials ==="
echo "Client ID: $(openssl rand -hex 16)"
echo "Client Secret: $(openssl rand -base64 32)"
echo "API Key: sk_$(openssl rand -hex 32)"
echo "JWT Secret: $(openssl rand -base64 32)"
echo ""
echo "=== Database ==="
echo "Password: $(openssl rand -base64 16)"
echo ""
echo "=== Encryption ==="
echo "Key: $(openssl rand -hex 32)"
echo "IV: $(openssl rand -hex 16)"
undefinedecho "=== API Credentials ==="
echo "Client ID: $(openssl rand -hex 16)"
echo "Client Secret: $(openssl rand -base64 32)"
echo "API Key: sk_$(openssl rand -hex 32)"
echo "JWT Secret: $(openssl rand -base64 32)"
echo ""
echo "=== Database ==="
echo "Password: $(openssl rand -base64 16)"
echo ""
echo "=== Encryption ==="
echo "Key: $(openssl rand -hex 32)"
echo "IV: $(openssl rand -hex 16)"
undefinedSecurity Notes
安全注意事项
- Always use cryptographically secure random generators
- Never use or similar pseudo-random functions
rand() - Use appropriate length (min 16 for passwords, 32 for keys)
- Store hashes, never store plain text
- Use unique salts for each password
- 始终使用加密安全的随机生成器
- 切勿使用或类似的伪随机函数
rand() - 使用合适的长度(密码至少16位,密钥至少32位)
- 存储哈希值,绝不存储明文
- 为每个密码使用唯一的盐值
Quick Commands
快速命令
| Task | Command |
|---|---|
| 16-char password | |
| 32-char API key | |
| UUID | |
| Random hex | |
| Random base64 | |
| 任务 | 命令 |
|---|---|
| 16位密码 | |
| 32位API密钥 | |
| UUID | |
| 随机十六进制字符串 | |
| 随机Base64字符串 | |