binarytext 0.1.0

Binary-to-text encoders / decoders
Documentation
  • Coverage
  • 66.13%
    41 out of 62 items documented0 out of 44 items with examples
  • Size
  • Source code size: 66.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.99 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lostinc0de

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==");