| Crates.io | base-d |
| lib.rs | base-d |
| version | 3.0.31 |
| created_at | 2025-11-23 07:32:15.165055+00 |
| updated_at | 2026-01-23 21:51:18.770712+00 |
| description | Universal base encoder: Encode binary data to 33+ dictionaries including RFC standards, hieroglyphs, emoji, and more |
| homepage | https://github.com/coryzibell/base-d |
| repository | https://github.com/coryzibell/base-d |
| max_upload_size | |
| id | 1946227 |
| size | 3,573,619 |

A universal, multi-dictionary encoding library and CLI tool for Rust. Encode binary data using numerous dictionaries including RFC standards, ancient scripts, emoji, playing cards, Matrix-style Japanese, and more.
base-d is a flexible encoding framework that goes far beyond traditional base64. It supports:
~/.config/base-d/dictionaries.toml./dictionaries.toml# Install (once published)
cargo install base-d
# Or build from source
git clone https://github.com/yourusername/base-d
cd base-d
cargo build --release
# List all available dictionaries
base-d config list
# Encode with playing cards (default)
echo "Secret message" | base-d encode
# RFC 4648 base32
echo "Data" | base-d encode base32
# Bitcoin base58
echo "Address" | base-d encode base58
# Egyptian hieroglyphics
echo "Ancient" | base-d encode hieroglyphs
# Emoji faces
echo "Happy" | base-d encode emoji_faces
# BIP-39 mnemonic words (human-readable)
echo "hello world" | base-d encode bip39
# Output: artist grace gloom bridge domain ivory rice ranch life
# Matrix-style base256
echo "Wake up, Neo" | base-d encode base256_matrix
# Enter the Matrix (live streaming random Matrix code)
base-d neo
# Auto-detect dictionary and decode
echo "SGVsbG8sIFdvcmxkIQ==" | base-d detect
# Show top candidates with confidence scores
base-d detect --show-candidates 5 input.txt
# Transcode between dictionaries (decode from one, encode to another)
echo "SGVsbG8=" | base-d decode base64 --encode hex
echo "48656c6c6f" | base-d decode hex --encode emoji_faces
# Compress and encode (supported: gzip, zstd, brotli, lz4, snappy, lzma)
echo "Data to compress" | base-d encode base64 --compress gzip
echo "Large file" | base-d encode base85 --compress zstd --level 9
echo "Fast compression" | base-d encode base64 --compress snappy
# Compress with default encoding (base64)
echo "Quick compress" | base-d encode --compress gzip
# Decompress and decode
echo "H4sIAAAAAAAA/..." | base-d decode base64 --decompress gzip
# Output raw compressed binary
echo "Data" | base-d encode --compress zstd --raw > output.zst
# Process files
base-d encode base64 input.txt > encoded.txt
base-d decode base64 encoded.txt > output.txt
# Compress large files efficiently
base-d encode base64 --compress brotli --level 11 large_file.bin > compressed.txt
# Hash files (supported: md5, sha256, sha512, blake3, ascon, k12, crc32, xxhash64, xxhash3, and more)
echo "hello world" | base-d hash sha256
echo "hello world" | base-d hash blake3 --encode base64
echo "hello world" | base-d hash ascon
echo "hello world" | base-d hash k12
echo "hello world" | base-d hash crc32
echo "hello world" | base-d hash xxhash3
base-d hash sha256 document.pdf
# Hash with custom seed
echo "hello world" | base-d hash xxhash64 --seed 42
# Hash with secret (XXH3 only)
cat secret.bin | base-d hash xxhash3 --secret-stdin data.bin
cargo install base-d
LLM-to-LLM wire protocol for structured data. Binary-packed, display-safe, parser-inert.
# Encode JSON
echo '{"users":[{"id":1,"name":"alice"}]}' | base-d schema
# Output: πΉβ£ββ₯βββ°β£β₯ββΊβββ°ββ€ββ§πΊ
# Decode
echo 'πΉβ£ββ₯βββ°β£β₯ββΊβββ°ββ€ββ§πΊ' | base-d schema -d
# With compression
base-d schema -c brotli input.json
# Pretty output
base-d schema -d --pretty encoded.txt
See SCHEMA.md for format specification.
Add to your Cargo.toml:
[dependencies]
base-d = "0.1"
use base_d::{DictionariesConfig, Dictionary, encode, decode};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load built-in dictionaries
let config = DictionariesConfig::load_default()?;
let dict_config = config.get_dictionary("base64").unwrap();
// Create dictionary from config
let chars: Vec<char> = dict_config.chars.chars().collect();
let padding = dict_config.padding.as_ref().and_then(|s| s.chars().next());
let dictionary = Dictionary::new_with_mode(
chars,
dict_config.mode.clone(),
padding
)?;
// Encode
let data = b"Hello, World!";
let encoded = encode(data, &dictionary);
println!("Encoded: {}", encoded); // SGVsbG8sIFdvcmxkIQ==
// Decode
let decoded = decode(&encoded, &dictionary)?;
assert_eq!(data, &decoded[..]);
Ok(())
}
use base_d::{DictionariesConfig, StreamingEncoder, StreamingDecoder};
use std::fs::File;
fn stream_encode() -> Result<(), Box<dyn std::error::Error>> {
let config = DictionariesConfig::load_default()?;
let dict_config = config.get_dictionary("base64").unwrap();
// ... create dictionary (same as above)
let mut input = File::open("large_file.bin")?;
let mut output = File::create("encoded.txt")?;
let mut encoder = StreamingEncoder::new(&dictionary, output);
encoder.encode(&mut input)?;
Ok(())
}
use base_d::{Dictionary, EncodingMode, encode};
fn custom_dictionary() -> Result<(), Box<dyn std::error::Error>> {
// Define a custom dictionary
let chars: Vec<char> = "ππππ€£πππ
ππππππππ₯°π".chars().collect();
let dictionary = Dictionary::new_with_mode(
chars,
EncodingMode::BaseConversion,
None
)?;
let encoded = encode(b"Hi", &dictionary);
println!("{}", encoded); // ππ
Ok(())
}
use base_d::DictionariesConfig;
// Load with user overrides from:
// 1. Built-in dictionaries
// 2. ~/.config/base-d/dictionaries.toml
// 3. ./dictionaries.toml
let config = DictionariesConfig::load_with_overrides()?;
// Or load from specific file
let config = DictionariesConfig::load_from_file("custom.toml".as_ref())?;
Encode and decode data using any dictionary defined in dictionaries.toml:
# List available dictionaries
base-d config list
# Encode from stdin (default dictionary is "cards")
echo "Hello, World!" | base-d encode
# Encode a file
base-d encode input.txt
# Encode with specific dictionary
echo "Data" | base-d encode dna
# Decode from specific dictionary
echo "SGVsbG8gV29ybGQNCg==" | base-d decode base64
# Decode playing cards
echo "ππ
πππ‘π£πΈππππππ΅π£π¨π»ππ" | base-d decode cards
# Transcode between dictionaries (no intermediate piping needed!)
echo "SGVsbG8=" | base-d decode base64 --encode hex
# Output: 48656c6c6f
# Convert between any two dictionaries
echo "ACGTACGT" | base-d decode dna --encode emoji_faces
echo "ππππ" | base-d decode cards --encode base64
# Stream mode for large files (memory efficient)
base-d encode base64 --stream large_file.bin > encoded.txt
base-d decode base64 --stream encoded.txt > decoded.bin
Add your own dictionaries to dictionaries.toml:
[dictionaries]
# Your custom 16-character dictionary
hex_emoji = "ππππ€£πππ
ππππππππ₯°π"
# Chess pieces (12 characters)
chess = "ββββββββββββ"
Or create custom dictionaries in ~/.config/base-d/dictionaries.toml to use across all projects. See Custom Dictionaries Guide for details.
base-d includes 55 pre-configured dictionaries organized into several categories:
Run base-d --list to see all available dictionaries with their encoding modes.
For a complete reference with examples and use cases, see DICTIONARIES.md.
base-d supports three encoding algorithms:
Mathematical Base Conversion (default) - Treats binary data as a single large number and converts it to the target base. Works with any dictionary size.
Bit-Chunking - Groups bits into fixed-size chunks for RFC 4648 compatibility (base64, base32, base16).
Byte Range - Direct 1:1 byte-to-character mapping using a Unicode range (like base100). Each byte maps to a specific emoji with zero encoding overhead.
For a detailed explanation of all modes with examples, see ENCODING_MODES.md.
MIT OR Apache-2.0
--neo flag deep diveContributions are welcome! Please see ROADMAP.md for planned features.