Rust
Rust
Get the JWE Protected Header
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.GetProtectedHeader, which copies the decoded shared JWE protected header into a JsonObject.
Background. Only the protected header is returned; it is not merged with the shared unprotected header or any per-recipient header.
Chilkat Rust Downloads
let jwe = chilkat::Jwe::new();
// Load the JWE.
let jwe_compact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>".to_string();
if jwe.load_jwe(&jwe_compact).is_err() {
println!("{}", jwe.last_error_text());
return;
}
// Copy the decoded shared JWE protected header into a JsonObject. Only the protected header is
// returned; it is not merged with the unprotected or per-recipient headers.
let json = chilkat::JsonObject::new();
if jwe.get_protected_header(&json).is_err() {
println!("{}", jwe.last_error_text());
return;
}
json.set_emit_compact(false);
println!("{}", json.emit().unwrap_or_default());