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 = new;
let test = "test";
let res = b.encode_from_str.unwrap;
assert_eq!;