# base32

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

Visionary Software Solutions Base32: RFC 4648 and Crockford base32 binary-to-text codecs

Encode binary data as Base32 text over the RFC 4648 standard alphabet, its Extended Hex alphabet, or Crockford's alphabet. The text is typed by its alphabet. Choose a factory for the required alphabet and its padding or hyphen policy.

## Key Concepts

### Codec contract

**Role.** Each alphabet's <code>Factory</code> makes a codec over that alphabet: RFC 4648's two make a <code>software.visionary.rfc4648.Codec</code>, and Crockford's a <code>software.visionary.cuneiform.codec.Codec</code> of the same symbols. <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 selection

**Role.** <code>rfc4648.Base32</code> and <code>rfc4648hex.Base32Hex</code> are RFC 4648's two alphabets, and their factories offer <code>PADDED</code> and <code>UNPADDED</code> codecs. <code>crockford.Crockford</code> is Crockford's, and its factory offers <code>TOLERANT</code>, which leaves hyphen separators out as it reads, and <code>STRICT</code>, which refuses them.

## Usage

Choose an alphabet and policy

```text
Package      Alphabet                 Factory choices
rfc4648      RFC 4648 standard         PADDED / UNPADDED
rfc4648hex   RFC 4648 Extended Hex     PADDED / UNPADDED
crockford    Crockford                TOLERANT / STRICT

```

Round-trip bytes with unpadded RFC 4648 Base32

```java
import java.util.Arrays;
import software.visionary.base32.rfc4648.Base32;
import software.visionary.base32.rfc4648.Factory;
import software.visionary.rfc4648.Codec;

class Base32RoundTrip {
    public static void main(String[] args) {
        Codec<Base32> codec = Factory.UNPADDED.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:rfc4648:2026.10.13` at Compile
- `software.visionary.spex:carlin:2026.10.13` at Compile
- `software.visionary:spex-closure:2026.10.13` at Testing

## Caveats

- RFC 4648 reading refuses lowercase letters and every character outside the selected alphabet. Crockford's strict codec refuses hyphens; it still reads a lowercase letter as its uppercase, <code>I</code> and <code>L</code> as <code>1</code>, and <code>O</code> as <code>0</code>.

