Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Jwe
string ls_JweCompact
oleobject loo_Json

li_Success = 0

loo_Jwe = create oleobject
li_rc = loo_Jwe.ConnectToNewObject("Chilkat.Jwe")
if li_rc < 0 then
    destroy loo_Jwe
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Load the JWE.
ls_JweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
li_Success = loo_Jwe.LoadJwe(ls_JweCompact)
if li_Success = 0 then
    Write-Debug loo_Jwe.LastErrorText
    destroy loo_Jwe
    return
end if

//  Copy the entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
//  decoded or merged JOSE header.
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

li_Success = loo_Jwe.GetHeader(loo_Json)
if li_Success = 0 then
    Write-Debug loo_Jwe.LastErrorText
    destroy loo_Jwe
    destroy loo_Json
    return
end if

loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()


destroy loo_Jwe
destroy loo_Json