Skip to main content

Module encoding

Module encoding 

Source
Expand description

Base32 and base64, in the two exact dialects atproto uses.

Both are strict, because the one property this whole crate exists to hold is that a value has exactly one encoding. Each refuses padding, and each refuses a final character whose unused low bits are set, which would decode to the same bytes and re-encode to a different string.

  • base32, lowercase, no padding, RFC 4648 alphabet. This is multibase b, which is the only string form atproto permits for a CID.
  • base64, standard alphabet (+ and /, not the URL-safe pair), no padding. This is the $bytes representation in the JSON form of the data model, and the base64 crate’s STANDARD_NO_PAD engine, which refuses both.

Enums§

DecodeError
Why a string is not valid lowercase unpadded base32.

Constants§

BASE32 🔒
The lowercase RFC 4648 base32 alphabet, which is multibase b.

Functions§

base32_decode
Decodes lowercase unpadded base32.
base32_encode
Encodes lowercase unpadded base32.
base64_decode
Decodes standard unpadded base64.
base64_encode
Encodes standard unpadded base64.
decode 🔒
Decodes a bit-packed string in alphabet, bits bits per character, under both strictness rules: no padding, and no set bits beyond the last whole byte.
encode 🔒
Encodes bytes bit-packed into alphabet, bits bits per character.