Sample code for 30+ languages & platforms
Visual FoxPro

Set the JWE Protected Header

See more JSON Web Encryption (JWE) Examples

Demonstrates Jwe.SetProtectedHeader, which sets the integrity-protected JWE header from a JsonObject. The header specifies the key-management algorithm (alg) and content-encryption algorithm (enc).

Background. The protected header is integrity-protected and applies to all recipients. It is configured before encrypting.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loJwe
LOCAL loHeader

lnSuccess = 0

loJwe = CreateObject('Chilkat.Jwe')

*  Build the JWE protected header.  The "alg" member names the key-management algorithm and the "enc"
*  member names the content-encryption algorithm.
loHeader = CreateObject('Chilkat.JsonObject')
loHeader.UpdateString("alg","A256KW")
loHeader.UpdateString("enc","A256GCM")

*  Set the protected header on the JWE.  The protected header is integrity-protected and applies to
*  all recipients.
lnSuccess = loJwe.SetProtectedHeader(loHeader)
IF (lnSuccess = 0) THEN
    ? loJwe.LastErrorText
    RELEASE loJwe
    RELEASE loHeader
    CANCEL
ENDIF

? "Protected header set."

RELEASE loJwe
RELEASE loHeader