A generalized binary text interface implementing different encoding / decoding schemes written in Rust.
Find a file
2026-02-24 23:22:22 +01:00
src Removed explicit base36 implementation and replaced it with general int encoder / Added base56, base58 and base62 2026-02-24 23:22:22 +01:00
.gitignore Updated main / Formatting 2026-02-18 22:51:32 +01:00
Cargo.toml Reduced to five keywords 2026-02-20 23:40:09 +01:00
README.md Updated README 2026-02-18 22:49:25 +01:00

binarytext - A binary-to-text encoder / decoder tool written in Rust

Motivation

This crate provides a basic interface for encoding and decoding byte streams and strings. Different binary-to-text encoders can share the same functionality this way. Additionally functions for reading from and writing to files using BufferedReader and BufferedWriter are available.

Current state

So far the following encoders have been implemented:

  • Base16
  • Base32
  • Base32Hex
  • Base36
  • Base45
  • Base64
  • Base64URL
  • Base85

All encoders have been tested using the examples from Wikipedia and / or the RFCs. For integer based encoders like Base36 the maximum length is 128 bit, since there is no support for big integers. Processing larger numbers will result in errors.

Examples

Use as a command-line utility

Encode the string "test" in Base64 and print the result "dGVzdA==" to stdout:

cargo r --release -- -t base64 -e "test" 

Decode the string "dGVzdA==" using Base64 and print the result "test" to stdout:

cargo r --release -- -t base64 -d "dGVzdA=="

If you leave out the parameter -t, the encoding type will be guessed using all suitable decoders:

cargo r --release -- -d "dGVzdA=="

Base64
"test"
Base64URL
"test"

Use as a library

You can add this crate as a library to your Rust application using cargo add or by editing your Cargo.toml.

let b = Base64::new();
let test = "test";
let res = b.encode_from_str(test).unwrap();
assert_eq!(res.as_str(), "dGVzdA==");