Skip to content

Repository files navigation

ascii-armor

https://img.shields.io/badge/tests-passing-brightgreen.svg https://img.shields.io/badge/FreeBSD-14.x-red.svg https://img.shields.io/badge/org--mode-literate-blue.svg https://img.shields.io/badge/license-MIT-green.svg

Overview

A validation suite for binary-in-text encoding patterns, from uuencode (1980) to org-mode babel blocks (2026). Every encoding claim is an executable round-trip test.

resources/codex-wallerstein-107v.jpg

Codex Wallerstein (c. 1470) — the Mordhau technique. Binary data, like a sword, must sometimes be disguised to pass through hostile channels.

The Problem

Foundational Axiom: A binary artifact must survive transit through a channel that only tolerates text.

Every encoding system solves the same constraint:

  • 7-bit SMTP channels reject 8-bit bytes
  • Text editors corrupt binary data
  • Patch utilities expect printable ASCII
  • Email headers have strict character limits

The solutions all converge on the same structure:

┌─────────────────────────────────────────┐
│  HEADER   name / type / encoding hint   │
│  PAYLOAD  ascii-safe encoded bytes      │
│  FOOTER   end marker / checksum         │
└─────────────────────────────────────────┘

Encoding Lineage

YearFormatChannel ConstraintOverhead
1980uuencodeUUCP / 7-bit email~37%
1983BinHexMac resource forks~35%
1987PEM/Base64Privacy-Enhanced Mail~33%
1989XBM/XPMX11 icons/cursors (C source)~400%
1990X-FacePine/Mutt/Gnus email facescustom
1985Ascii85PostScript/PDF (btoa)~25%
1992MIME Base64RFC 2045 email~33%
1998data: URIRFC 2397 web embedding~33%
2005Git binaryPatch files~25%
2018org-modeLiterate programming~33%

API/Schema Specifications (formalized patterns)

YearFormatChannel ConstraintSpec
2000SOAP base64XML textxs:base64Binary
2005MTOM/XOPSOAP + MIME attachmentW3C (avoids base64 overhead)
2013JSON SchemaJSON textcontentEncoding + contentMediaType
2017OpenAPI 3.0REST API responseformat: byte / binary
2021OpenAPI 3.1REST API responseJSON Schema contentEncoding
// JSON Schema for base64-encoded PNG
{
  "type": "string",
  "contentEncoding": "base64",
  "contentMediaType": "image/png"
}

Serial/Modem Variants (the direct ancestors)

YearFormatChannel ConstraintNotes
1977XMODEMSerial/modem (async)128B blocks, checksum
1985YMODEMSerial/modem (async)1K blocks, batch mode
1986ZMODEMSerial/modem (async)Streaming, Ctrl-char escape
1988SLIPSerial line (IP)END=0xC0, ESC=0xDB framing
1994PPPSerial line (IP)HDLC 0x7E framing, 0x7D esc

Audio/Radio Variants (same pattern, different channel)

YearFormatChannel ConstraintNotes
1976Kansas City StdCassette tape (audio)1200/2400 Hz FSK
1980BASICODERadio broadcast (Netherlands)NOS/BBC/WDR/DDR
1963NOAA APTVHF radio (137 MHz)TIROS-8 weather sat
2020LoRa/MeshtasticSub-GHz radio (900 MHz)Text over mesh networks
2024NASA DSOCLaser (1550nm optical)Deep space optical comm

resources/gladiatoria-kk5013-28v.jpg

Gladiatoria (c. 1430) — armored combat. Like knights donning armor, binary data dons ASCII encoding to survive hostile text channels.

What This Builds

  • spec.org — Literate test suite (the spec is the tests)
  • bin/check-prereqs.sh — Tool availability check
  • bin/test-*.sh — Round-trip tests for each encoding
  • elisp/display-helpers.el — Org-mode inline image support
  • Makefile — Tangle and test runner

Quick Start

# Clone
git clone https://github.com/aygp-dr/ascii-armor.git
cd ascii-armor

# Check prerequisites
make prereq

# Generate fixtures and run tests
make test

# Or execute the entire spec in Emacs
make test-org

FreeBSD Requirements

Base system (already installed):

  • uuencode / uudecode
  • b64encode / b64decode
  • xxd

Packages:

pkg install git              # Required
pkg install sharutils        # Optional: GNU shar
pkg install ImageMagick7     # Optional: XBM/XPM conversion

See INSTALL-FREEBSD.md for details.

Methodology

Spec is the Test Suite

Every #+begin_src block in spec.org is executable via C-c C-c. If it cannot be executed, it is marked :eval no.

Round-Trip Acceptance

For each encoding, the test is:

encode(decode(encode(x))) == encode(x)

Partial coverage (encode only) is not sufficient.

Tool Detection First

Every shell block verifies tools are on PATH before use. Missing tools produce structured JSON errors, not silent failures.

Conjectures (CPRR)

Open hypotheses are tracked and testable:

IDHypothesisRefutation
C-001All required tools in FreeBSD 14 basecheck-prereqs exits 2
C-003uuencode overhead ~37%measured < 35%
C-009Ascii85 overhead ~25%measured > 27%
C-011compface not in FreeBSD portspkg install succeeds

Project Structure

ascii-armor/
├── spec.org              # Literate test suite (source of truth)
├── CLAUDE.md             # Agent instructions
├── Makefile              # Build/test runner
├── INSTALL-FREEBSD.md    # Package installation guide
├── bin/
│   ├── check-prereqs.sh  # Tool availability check
│   ├── test-uuencode.sh  # uuencode round-trip
│   ├── test-b64encode.sh # base64 round-trip
│   └── ...
├── elisp/
│   └── display-helpers.el
├── resources/
│   ├── codex-wallerstein-107v.jpg
│   ├── gladiatoria-kk5013-28v.jpg
│   └── SOURCES.md
└── archive/
    └── spec-v1-*.org     # Previous spec versions

References

License

MIT

Image Credits

Medieval fencing manuscripts from Wikimedia Commons (public domain):

  • Codex Wallerstein (c. 1470) — Universitätsbibliothek Augsburg
  • Gladiatoria Ms. KK5013 (c. 1430) — Kunsthistorisches Museum Vienna

About

Binary-in-text encoding validation suite: uuencode, MIME Base64, XBM/XPM, X-Face, Ascii85, data URIs, org-mode. Literate FreeBSD test suite.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages