# base16

`software.visionary:base16:2026.10.13` · https://codeberg.org/notations/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.** <code>Factory.INSTANCE</code> makes a <code>software.visionary.rfc4648.Codec</code> over the alphabet <code>Base16</code>. <code>deserialize</code> encodes bytes as <code>Encoded</code> data, whose <code>toString()</code> is the text; <code>read</code> takes text to encoded data, and <code>serialize</code> decodes that to bytes.

### Alphabet

**Role.** <code>Base16</code> is an enum of <code>0–9</code> and <code>A–F</code>, whose constants pick their glyphs. Each byte is two symbols, so there is no padding.

## Usage

Encode bytes and recover the original data

```java
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.13` at Compile
- `software.visionary:spex-closure:2026.10.13` at Testing

## Caveats

- Reading accepts only <code>0–9</code> and <code>A–F</code>; it refuses lowercase letters and every other character. Decoding refuses an odd number of symbols.

