std/encoding/base32

std/encoding/src/base32.trb

Base32 (RFC 4648 sections 6 and 7): Base32Alphabet.Standard (A-Z, 2-7), what NATS NKeys and a TOTP secret are written in, and Base32Alphabet.Extended (0-9, A-V), which sorts the same as the bytes it stands for.

Unlike Base64's two alphabets, these two are not read together: A means 0 in one and 10 in the other, so Base32Alphabet.decoded takes the alphabet the text was written in.

type Base32Alphabet

type Base32Alphabet with Show, Equals, Hash

Which of RFC 4648's two Base32 alphabets a text is written in.

case Standard

case Standard

RFC 4648 section 6: A-Z and 2-7.

case Extended

case Extended

RFC 4648 section 7 ("base32hex"): 0-9 and A-V.

fn encoded

fn encoded(bytes: Bytes, padded: Bool = true): String

bytes written in this alphabet, padded with = to a multiple of eight characters unless padded is false.

fn decoded

fn decoded(text: String): Result<Bytes, EncodingError>

The bytes a Base32 text in this alphabet stands for, padded or not, with whitespace inside it skipped.

Errors

  • EncodingError for a character outside this alphabet, or padding before the end.