Salt 随机值生成器 Salt Generator
生成随机 Salt,用于哈希加盐测试与演示;支持 Hex / Base64 / URL-safe 等常见输出格式,并可批量生成。
Generate random salts for hashing demos and testing. Supports Hex / Base64 / URL-safe formats and batch output.
1. 生成参数 · Generator Settings
3. 使用说明 · Notes(多写点 · Extended)
-
Salt 是什么?· What is a salt?
Salt(盐)是加到密码/消息前后的随机字符串或随机字节序列,用于让同样的明文在哈希后产生不同结果, 从而抵抗“彩虹表”与批量撞库等攻击方式。
A salt is random data added before/after a password/message so identical inputs produce different hashes, helping defend against rainbow tables and large-scale precomputed attacks. -
Salt 应该多长?· How long should a salt be?
常见建议是 16 bytes(128-bit) 或 32 bytes(256-bit)。如果只是演示或简单测试, 16 bytes 已足够;若你希望更“宽松”的安全余量,可用 32 bytes。
Common recommendations are 16 bytes (128-bit) or 32 bytes (256-bit). For demos/tests, 16 bytes is usually enough; 32 bytes provides extra margin. -
Hex vs Base64/URL-safe:怎么选?· Hex vs Base64/URL-safe: which to choose?
Hex:可读性最好,字符集最简单,日志/配置里不容易出幺蛾子;缺点是同等字节数下更长。
Base64:更短,但包含 + / =, 在 URL、文件名、某些系统字段里可能需要转义。
Base64URL:用 – _ 代替 + /, 并去掉填充 =,更适合 URL/Token 场景。
Hex is simplest; Base64 is shorter but may need escaping; Base64URL is URL-friendly and commonly used in tokens. -
Salt 需要保密吗?· Does a salt need to be secret?
通常 Salt 不需要保密,很多系统会把 salt 与哈希值一起存储(例如数据库字段)。真正需要保密的是用户的密码、 以及用于签名/加密的密钥(key/secret)。
Usually salts do not need to be secret and are often stored alongside password hashes. What must remain secret are passwords and cryptographic keys/secrets. -
“前缀/后缀”有什么用?· What are prefix/suffix for?
这里的前/后缀主要用于演示与工程习惯:比如给 salt 加上 env:、v1 之类的标识, 便于排查与区分用途。但它们不会增加随机性;随机性只来自“随机字节数”。
Prefix/suffix are for labeling and debugging convenience; they do not add randomness—bytes do. -
关于“加盐哈希”的小提醒 · Practical reminder
如果你做的是“密码存储”,请优先使用专门的密码哈希算法(如 bcrypt / scrypt / Argon2 等), 不要自己随便用 SHA-256 + salt 直接拼接就上线。这个工具更适合:接口测试、演示、样例数据、学习验证流程。
For password storage, prefer purpose-built password hashing (bcrypt/scrypt/Argon2) instead of rolling your own SHA-256 + salt concatenation. This tool is best for testing, demos, and learning workflows.
说明:本工具使用浏览器 Web Crypto API(crypto.getRandomValues)在本地生成随机字节,
不会上传或保存你的输入与结果。生成结果仅供测试与演示用途,请根据你的系统规范(字段长度、字符集、编码)选择合适的格式与长度。
Note: This tool generates random bytes locally via Web Crypto API (crypto.getRandomValues).
Nothing is uploaded or stored. Choose format/length based on your system constraints (field length, charset, encoding).
