Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 0
set jwe [new_CkJwe]
# Load the JWE.
set jweCompact "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
set success [CkJwe_LoadJwe $jwe $jweCompact]
if {$success == 0} then {
puts [CkJwe_lastErrorText $jwe]
delete_CkJwe $jwe
exit
}
# Copy the entire loaded JWE structure into a JsonObject. This is the full JWE representation, not a
# decoded or merged JOSE header.
set json [new_CkJsonObject]
set success [CkJwe_GetHeader $jwe $json]
if {$success == 0} then {
puts [CkJwe_lastErrorText $jwe]
delete_CkJwe $jwe
delete_CkJsonObject $json
exit
}
CkJsonObject_put_EmitCompact $json 0
puts [CkJsonObject_emit $json]
delete_CkJwe $jwe
delete_CkJsonObject $json