# base45

`software.visionary:base45:2026.10.13` · https://codeberg.org/notations/base45

Visionary Software Solutions Base45: RFC 9285 base45 binary-to-text codec

Encode bytes as Base45 text and decode that text back to bytes, over the alphabet of RFC 9285, which a QR code holds compactly. The text is typed by that alphabet.

## Key Concepts

### Codec contract

**Role.** <code>Factory.INSTANCE</code> makes a <code>software.visionary.cuneiform.codec.Codec</code> whose text holds the constants of <code>Base45</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>Base45</code> is an enum of <code>0–9</code>, <code>A–Z</code>, the space and <code>$ % * + - . / :</code>, whose constants pick their glyphs. A constant's place in the enum is its base-45 digit.

### Base conversion

**Role.** Base45 converts numbers; it does not regroup bits. Two bytes are a number written as three digits, least significant first, and a last single byte is written as two.

## Usage

Round-trip bytes through Base45

```java
import java.util.Arrays;
import software.visionary.base45.Base45;
import software.visionary.base45.Factory;
import software.visionary.cuneiform.codec.Codec;

class Base45RoundTrip {
    public static void main(String[] args) {
        Codec<Base45> codec = Factory.INSTANCE.create();
        byte[] original = {0x12, 0x34, (byte) 0xAB};
        String written = codec.deserialize(original).toString();
        System.out.println(written + " " + Arrays.equals(original, codec.serialize(codec.read(written))));
    }
}

```

## Dependencies

- `software.visionary.cuneiform:codec:2026.10.13` at Compile
- `software.visionary:spex-closure:2026.10.13` at Testing

## Caveats

- Reading refuses every character outside the alphabet; the space belongs to it, so it must be kept. Decoding refuses a lone last symbol and a group whose number is more than its bytes hold.

