rfc4648
Visionary Software Solutions RFC 4648: the codecs of base16, base32 and base64, unpadded and padded, whose text is written and read a group at a time
The codecs RFC 4648 describes for an alphabet of four, five or six bits, unpadded and padded: base16, base32 and base64. Their contract is software.visionary.cuneiform.codec's; this module seals what their text holds and makes them.
Key Concepts
Sealed symbols
Role. Symbol extends software.visionary.cuneiform.codec.Symbol and is sealed: a symbol of an RFC 4648 text is a constant of its alphabet or the pad. A switch over one needs no default. Codec<A> is a codec whose text holds Symbol<A>, and is sealed too: this module makes every one.
Alphabets
Role. The alphabet of base16, base32 or base64 is an enum that implements TetAlphabet. Each constant picks its glyph and stands for a tet of bits, as wide as the base needs; its place in the enum is the number those bits hold, as in the RFC's tables.
Making a codec
Role. CodecFactory makes the unpadded codec of an alphabet, or, given a pad's glyph, the padded one: encoding completes the last group with pads, and decoding demands exactly those pads, at the end. It picks the codec by how many bits a symbol stands for, and refuses an alphabet of three bits or of seven, which RFC 4648 describes no codec for. Base16 has no short group, so its codec neither writes nor reads a pad.
Groups
Role. Text is written and read a group at a time, and a group is one of the shapes the RFC gives its base and nothing else. In base64 that is four symbols for three octets, or at the end three for two or two for one. In base32 it is eight symbols for five octets, or at the end seven, five, four or two. In base16 it is two symbols for one octet. A group holds constants of its alphabet, so it holds no pad, and a short one is never made of symbols whose filler bits are not zero. Reading counts nothing: it knows its place in a group, and each place says what a symbol, a pad and the end of the text mean there.
Strict decoding
Role. A character outside the alphabet is refused with DemandFailedException; a line break is outside every alphabet. So are a last symbol that carries no octet, bits after the last octet that are not zero, and a missing, extra or misplaced pad. A view refuses when its walk reaches what it refuses. serialize walks to the end, so it refuses before it returns.
Usage
Make the padded and unpadded codecs of an alphabet
import software.visionary.cuneiform.graphic.Punctuation;
import software.visionary.rfc4648.Codec;
import software.visionary.rfc4648.CodecFactory;
import software.visionary.rfc4648.TetAlphabet;
import software.visionary.wheeler.Bit;
import software.visionary.wheeler.tets.Tet;
class Codecs {
static <A extends Enum<A> & TetAlphabet<A, B>, B extends Tet<?, ? extends Bit>> Codec<A> unpadded(final A alphabet) {
return new CodecFactory<>(alphabet).create();
}
static <A extends Enum<A> & TetAlphabet<A, B>, B extends Tet<?, ? extends Bit>> Codec<A> padded(final A alphabet) {
return new CodecFactory<>(alphabet, Punctuation.EQUALS_SIGN).create();
}
}
Dependencies
software.visionary.cuneiform:codec:2026.10.13at Compilesoftware.visionary.contrax:processor:2026.10.13at Processorsoftware.visionary:spex-closure:2026.10.13at Testing
Views
Drawn from the release. A link in a view opens its source at the release tag.