Base58 校验长度

🔤 Base58 Checked Length

From raw byte length, estimate the Base58-encoded string length including the 4-byte checksum, as used for Bitcoin-style addresses.

📐 计算公式与说明

总字节数 = 载荷字节数 + 校验字节数 + 版本字节数;Base58 估算长度 = ceil(总字节数 × 8 ÷ 5.86)(每字符约携带 log₂58 ≈ 5.86 bit,折合每字节约 1.365 个字符)。校验:无强校验,三项字节数缺省按 0。判据:估算为向上取整的理论长度,实际编码因前导零等规则可能略有出入。

常用于加密货币地址长度估算。

📚 深度解析:Base58 校验长度

💡 常见使用场景

示例:比特币 P2PKH 地址
版本 1 字节 + 公钥哈希 20 字节 + 校验 4 字节 = 25 字节,Base58 编码约 34 字符。

❓ 常见问题(FAQ)

为何用 Base58 而非 Base64?
Base58 去除 0/O/1/l/I 等易混字符,降低人工抄写出错率。
校验和做什么?
4 字节双 SHA256 前段,用于检测地址输入错误。
长度为何不是整数倍?
Base58 非 2 的幂分组,长度随数值近似 ⌈n·log(256)/log(58)⌉。

Formula & Standard References

Item Formula / Rule Source / Standard
Length estimate L ≈ ⌈8n ÷ log258⌉ with log258 ≈ 5.858 Bitcoin Base58Check encoding (protocol documentation)
Alphabet 58 symbols, dropping the look-alikes 0, O, I and l Bitcoin Base58Check encoding, alphabet definition
Checksum suffix Base58Check appends a 4-byte double-SHA-256 checksum before encoding the whole payload Bitcoin Base58Check encoding, checksum step