Skip to content

std.base32

rfc 4648; strict: padding as the codec says, lowercase ok, no whitespace

pub Base32Error :: errors {
invalid_character,
invalid_length,
buffer_too_small,
}
  • invalid_character: not in the alphabet, or a stray =
  • invalid_length: a length no encoding has
  • buffer_too_small: out too small; nothing written
pub Codec :: struct {
chars: []const u8,
pad: bool,
}

alphabet and padding

pub encoded_len :: fn(self: *Self, n: usize) -> usize

text length for n bytes

pub decoded_len :: fn(self: *Self, text: []const u8) -> usize ! Base32Error

byte length of well-formed text

pub encode :: fn(self: *Self, out: []u8, src: []const u8) -> usize ! Base32Error

into out; returns the length (encoded_len)

pub decode :: fn(self: *Self, out: []u8, text: []const u8) -> usize ! Base32Error

into out; returns the length; bits past the last whole byte ignored

pub encode_in :: fn(self: *Self, a: *Arena, src: []const u8) -> []u8

in a

pub decode_in :: fn(self: *Self, a: *Arena, text: []const u8) -> []u8 ! Base32Error

in a

pub STANDARD: Codec = .{ STANDARD_CHARS, true }
pub STANDARD_NO_PAD: Codec = .{ STANDARD_CHARS, false }
pub HEX: Codec = .{ HEX_CHARS, true }
pub HEX_NO_PAD: Codec = .{ HEX_CHARS, false }
pub encode_in :: fn(a: *Arena, src: []const u8) -> []u8

STANDARD.encode_in; in a

pub decode_in :: fn(a: *Arena, text: []const u8) -> []u8 ! Base32Error

STANDARD.decode_in; in a