Sample code for 30+ languages & platforms
Rust

Get Contents of File as Base64

See more Encryption Examples

Demonstrates how to read the contents of a file and convert to a base64 string.

Chilkat Rust Downloads

Rust

let bd = chilkat::BinData::new();

if bd.load_file("qa_data/jpg/starfish.jpg").is_err() {
    println!("Failed to load file.");
    return;
}

println!("{}", bd.get_encoded("base64").unwrap_or_default());

// If you want mult-line base64:
println!("--");
println!("{}", bd.get_encoded("base64_mime").unwrap_or_default());

// If you want hex..
println!("--");
println!("{}", bd.get_encoded("hex").unwrap_or_default());

// etc..