DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoJwe
Variant vHeader
Handle hoHeader
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatJwe)) To hoJwe
If (Not(IsComObjectCreated(hoJwe))) Begin
Send CreateComObject of hoJwe
End
// Build the JWE protected header. The "alg" member names the key-management algorithm and the "enc"
// member names the content-encryption algorithm.
Get Create (RefClass(cComChilkatJsonObject)) To hoHeader
If (Not(IsComObjectCreated(hoHeader))) Begin
Send CreateComObject of hoHeader
End
Get ComUpdateString Of hoHeader "alg" "A256KW" To iSuccess
Get ComUpdateString Of hoHeader "enc" "A256GCM" To iSuccess
// Set the protected header on the JWE. The protected header is integrity-protected and applies to
// all recipients.
Get pvComObject of hoHeader to vHeader
Get ComSetProtectedHeader Of hoJwe vHeader To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoJwe To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Protected header set."
End_Procedure