Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

Get Base64 Public Key from Private Key

See more ECC Examples

Demonstrates how to get the public key in base64 format from a private key.

Chilkat Rust Downloads

Rust

// Load a private key from base64.
let bd = chilkat::BinData::new();
let _ = bd.append_encoded("MHQCA....n0Q==", "base64").is_ok();

let priv_key = chilkat::PrivateKey::new();
if priv_key.load_any_format(&bd, "").is_err() {
    println!("{}", priv_key.last_error_text());
    return;
}

let pub_key = chilkat::PublicKey::new();
let _ = priv_key.to_public_key(&pub_key);

let pub_key_base64 = pub_key.get_encoded(true, "base64").unwrap_or_default();
println!("{}", pub_key_base64);