Sample code for 30+ languages & platforms
Lianja

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

Lianja
llSuccess = .F.

loJwe = createobject("CkJwe")

//  Load the JWE.
lcJweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
llSuccess = loJwe.LoadJwe(lcJweCompact)
if (llSuccess = .F.) then
    ? loJwe.LastErrorText
    release loJwe
    return
endif

//  Copy the entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
//  decoded or merged JOSE header.
loJson = createobject("CkJsonObject")
llSuccess = loJwe.GetHeader(loJson)
if (llSuccess = .F.) then
    ? loJwe.LastErrorText
    release loJwe
    release loJson
    return
endif

loJson.EmitCompact = .F.
? loJson.Emit()


release loJwe
release loJson