哈希输出长度

#️⃣ Hash Output Length

Look up the output length (bytes and bits) of common hash algorithms (MD5, SHA family) for hash value storage planning.

📐 计算公式与说明

MD5=128bit, SHA1=160bit, SHA256=256bit, SHA512=512bit
Hex 长度 = 字节数 × 2

用于预估哈希值存储空间。

📚 深度解析:哈希输出长度

💡 常见使用场景

示例:SHA-256
输出 256 bit = 32 字节 = 64 个十六进制字符。

❓ 常见问题(FAQ)

MD5 还能用吗?
仅用于非安全校验(如去重),因其已被攻破不可用于完整性/防篡改。
位数与安全性关系?
抗碰撞强度约与位数半相关(生日攻击),SHA-256 远强于 MD5/SHA-1。
为何同时给字节与位数?
存储按字节、展示常用十六进制(2 字符/字节),两者都常用。

Formula & Standard References

Item Formula / Rule Source / Standard
Digest length Fixed per algorithm: MD5 128 bits, SHA-1 160, SHA-256 256, SHA-512 512 FIPS 180-4 Secure Hash Standard / RFC 1321
Serialized length Hex length = bits / 4; Base64 length = 4 × ⌈(bits/8) / 3⌉ RFC 4648 §4 / ISO/IEC 10118-3
Collision bound A collision is expected near 2n/2 trials by the birthday bound, with n the digest bits NIST SP 800-107 Rev.1 §4 Hash function security