Aller au contenu
uencoder

Multibase Codage Explained

Understand le multibase self-identifying codage scheme utilisé en IPFS et decentralized systèmes.

问题

You see chaînes prefixed avec single letters (comme b, f, B) et besoin en understand le multibase convention ce self-identifies le codage.

Prérequis

  • Familiarity with Base64, Base32, and hex
  • Understanding of self-describing formats

Étapes

  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.

    entrée
    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).

    entrée
    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.

    entrée
    bAAEC
    输出
    decode as Base64url → bytes [0,1,2]

Résultat attendu

Un self-identifying encoded chaîne ce any multibase-aware consumer peut décoder sans prior knowledge de le codage.

Erreurs courantes

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.

Dépannage指引

  • 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.

Limites de sécurité

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

Outils associés

Termes associés

参考链接