Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loJwe
LOCAL lcJweCompact
LOCAL loJson

lnSuccess = 0

loJwe = CreateObject('Chilkat.Jwe')

*  Load the JWE.
lcJweCompact = "eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>"
lnSuccess = loJwe.LoadJwe(lcJweCompact)
IF (lnSuccess = 0) THEN
    ? loJwe.LastErrorText
    RELEASE loJwe
    CANCEL
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('Chilkat.JsonObject')
lnSuccess = loJwe.GetHeader(loJson)
IF (lnSuccess = 0) THEN
    ? loJwe.LastErrorText
    RELEASE loJwe
    RELEASE loJson
    CANCEL
ENDIF

loJson.EmitCompact = 0
? loJson.Emit()

RELEASE loJwe
RELEASE loJson