Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oJwe
LOCAL oHeader
nSuccess := 0
oJwe := 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.
oHeader := CreateObject("Chilkat.JsonObject")
oHeader:UpdateString("alg", "A256KW")
oHeader:UpdateString("enc", "A256GCM")
// Set the protected header on the JWE. The protected header is integrity-protected and applies to
// all recipients.
nSuccess := oJwe:SetProtectedHeader(oHeader)
IF (nSuccess == 0)
? oJwe:LastErrorText
oJwe:destroy()
oHeader:destroy()
RETURN
ENDIF
? "Protected header set."
oJwe:destroy()
oHeader:destroy()