跳到主要内容
uencoder

Multibase Encoding Explained

Understand multibase self-identifying 编码 scheme used 在 IPFS 和 decentralized systems.

问题

你 see strings prefixed 具有单个 letters (like b, f, B) 和 need 到理解 multibase 约定该 self-identifies 编码.

前置条件

  • 熟悉Base64, Base32, 和 hex
  • Understanding 的 self-describing formats

步骤

  1. 1. Learn the prefix table

    Multibase prepends a single character to indicate the encoding: B for Base64, b for Base64url, f for hexadecimal, F for uppercase hex, z for Base58 Bitcoin, and K for Base36. This lets a consumer detect the encoding without external metadata.

    输入
    f4d2
    输出
    hex encoding of 0x4d2
  2. 2. Encode with the correct prefix

    Choose the encoding that fits your needs, encode the data, and prepend the corresponding prefix. For binary data in URLs, use b (Base64url). For compact human-readable codes, use z (Base58).

    输入
    binary data
    输出
    bAAEC (Base64url with prefix)
  3. 3. Decode by inspecting the prefix

    Read the first character to determine the encoding, strip it, and decode the rest using the identified base. A multibase decoder handles all supported prefixes automatically.

    输入
    bAAEC
    输出
    decode as Base64url → bytes [0,1,2]

预期结果

self-identifying encoded 字符串该 任何 multibase-aware 消费者能够解码无 prior 知识的 编码.

常见错误

Forgetting to strip the prefix before decoding
The first character is the encoding marker, not part of the data. Remove it before passing to the base-specific decoder.
Using the wrong prefix for the encoding
Refer to the multibase table. Using B (Base64) when you meant b (Base64url) will produce different output.

排障指引

  • If decoding fails, check the prefix against the multibase table to confirm it matches the actual encoding.
  • Multibase is used in IPFS CIDs; the prefix is part of a larger self-describing structure.

安全限制

  • Multibase is a transport encoding. It provides no confidentiality or integrity guarantees.

相关工具

相关词条

参考链接