Rust Requires Chilkat v11.0.0+
Rust
RSASSA-PSS Algorithm with SHA256 Hashing
See more RSA Examples
RSA encrypt a SHA256 hash with OAEP padding.Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let privkey = chilkat::PrivateKey::new();
// Load the private key object from a PEM file.
// (To load from a PEM string, call LoadPem instead.)
if privkey.load_pem_file("somePath/myPrivateKey.pem").is_err() {
println!("{}", privkey.last_error_text());
return;
}
let rsa = chilkat::Rsa::new();
// Use RSA-PSS by setting PkcsPadding = false
rsa.set_pkcs_padding(false);
// Use SHA256
rsa.set_oaep_hash("SHA-256");
let _ = rsa.use_private_key(&privkey);
// Generate a base64 signature.
rsa.set_encoding_mode("base64");
let Ok(sig_str) = rsa.sign_string_enc("String to be signed", "SHA-256") else {
println!("{}", rsa.last_error_text());
return;
};
println!("Signature: {}", sig_str);