Perl
Chilkat2 Perl
Get the Entire Loaded JWE Structure
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.GetHeader, which copies the entire currently loaded JWE structure into a JsonObject.
Background. This is the full JWE representation, not a decoded or merged JOSE header. It can contain the protected, unprotected, and per-recipient header material.
Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $jwe = Chilkat2::Jwe->new;
# Load the JWE.
my $jweCompact = 'eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>';
my $success = $jwe->LoadJwe($jweCompact);
if (!$success) {
print $jwe->LastErrorText, "\n";
exit;
}
# Copy the entire loaded JWE structure into a JsonObject. This is the full JWE representation, not a
# decoded or merged JOSE header.
my $json = Chilkat2::JsonObject->new;
$success = $jwe->GetHeader($json);
if (!$success) {
print $jwe->LastErrorText, "\n";
exit;
}
$json->EmitCompact(0);
print $json->Emit(), "\n";