Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oJwe
LOCAL cJweCompact
LOCAL oJson

nSuccess := 0

oJwe := CreateObject("Chilkat.Jwe")

//  Load the JWE.
cJweCompact := "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
nSuccess := oJwe:LoadJwe(cJweCompact)
IF (nSuccess == 0)
    ? oJwe:LastErrorText
    oJwe:destroy()
    RETURN
ENDIF

//  Copy the entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
//  decoded or merged JOSE header.
oJson := CreateObject("Chilkat.JsonObject")
nSuccess := oJwe:GetHeader(oJson)
IF (nSuccess == 0)
    ? oJwe:LastErrorText
    oJwe:destroy()
    oJson:destroy()
    RETURN
ENDIF

oJson:EmitCompact := 0
? oJson:Emit()

oJwe:destroy()
oJson:destroy()