base16
Visionary Software Solutions Base16: RFC 4648 §8 hexadecimal binary-to-text codec
Encode bytes as uppercase hexadecimal text and decode that text back to bytes, over the Base 16 Alphabet of RFC 4648 §8. The text is typed by that alphabet.
Key Concepts
Codec contract
Role. Factory.INSTANCE makes a software.visionary.rfc4648.Codec over the alphabet Base16. deserialize encodes bytes as Encoded data, whose toString() is the text; read takes text to encoded data, and serialize decodes that to bytes.
Alphabet
Role. Base16 is an enum of 0–9 and A–F, whose constants pick their glyphs. Each byte is two symbols, so there is no padding.
Usage
Encode bytes and recover the original data
import java.util.Arrays;
import software.visionary.base16.Base16;
import software.visionary.base16.Factory;
import software.visionary.rfc4648.Codec;
class HexRoundTrip {
public static void main(String[] args) {
Codec<Base16> codec = Factory.INSTANCE.create();
byte[] original = {0x12, 0x34, (byte) 0xAB};
String hexadecimal = codec.deserialize(original).toString();
System.out.println(hexadecimal + " " + Arrays.equals(original, codec.serialize(codec.read(hexadecimal))));
}
}
Dependencies
software.visionary:rfc4648:2026.10.13at Compilesoftware.visionary:spex-closure:2026.10.13at Testing
Caveats
- Reading accepts only
0–9andA–F; it refuses lowercase letters and every other character. Decoding refuses an odd number of symbols.
Views
Drawn from the release. A link in a view opens its source at the release tag.