コンテンツへスキップ
uencoder

Multibase エンコーディングの解説

IPFS や分散型システムで使われる、自己識別型の multibase エンコーディング方式を理解します。

问题

b、f、B のような 1 文字の接頭辞が付いた文字列を目にし、エンコーディングを自己識別する multibase の規約を理解する必要があります。

前提条件

  • Base64、Base32、16 進表記への習熟
  • 自己記述形式の理解

ステップ

  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]

期待される結果

multibase 対応の利用者なら誰でも、エンコーディングの事前知識なしにデコードできる、自己識別型のエンコード文字列。

よくあるエラー

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.

関連ツール

関連用語

参考链接