Tcl
Tcl
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 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 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.
set json [new_CkJsonObject]
set success [CkJwe_GetProtectedHeader $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