Rust Base64 Codec CLI
Rust Base64 Codec — a runnable rust project with source, install and run commands, and expected output.
Project
rust-base64-cli
Entry point: main.rs
Install
cargo run -- encode helloRun
cargo run -- encode helloTest
cargo testExpected output
Encodes a string to base64 and prints it.Dependencies
- rust >=1.75
- base64 0.22
Verification evidence
Source reviewed against rust standard library APIs. Commands verified for syntax; execution not yet exercised in CI.
Security note
Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.
What it does
Rust Base64 Codec CLI is a self-contained rust command-line program. Encodes a string to base64 and prints it.
Install and run
cargo run -- encode hello
cargo run -- encode hello
Project structure
rust-base64-cli/
├── main.rs
└── README snippet above
Key source
// main.rs
use base64::{engine::general_purpose::STANDARD, Engine};
fn main() {
let args: Vec<String> = std::env::args().collect();
if args[1] == "encode" {
println!("{}", STANDARD.encode(&args[2]));
} else {
let b = STANDARD.decode(&args[2]).unwrap();
println!("{}", String::from_utf8(b).unwrap());
}
}
Testing
cargo test
Expected output
When run with the documented command, the program prints:
aGVsbG8= (base64 of "hello")
This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.
Limitations
- The program is a single-file CLI with no external service dependencies.
- Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
- Execution has been reviewed for correctness but not yet exercised in an automated CI run.