Delphi DLL
Delphi DLL
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 Delphi DLL Downloads
var
success: Boolean;
jwe: HCkJwe;
header: HCkJsonObject;
begin
success := False;
jwe := CkJwe_Create();
// Build the JWE protected header. The "alg" member names the key-management algorithm and the "enc"
// member names the content-encryption algorithm.
header := CkJsonObject_Create();
CkJsonObject_UpdateString(header,'alg','A256KW');
CkJsonObject_UpdateString(header,'enc','A256GCM');
// Set the protected header on the JWE. The protected header is integrity-protected and applies to
// all recipients.
success := CkJwe_SetProtectedHeader(jwe,header);
if (success = False) then
begin
Memo1.Lines.Add(CkJwe__lastErrorText(jwe));
Exit;
end;
Memo1.Lines.Add('Protected header set.');
CkJwe_Dispose(jwe);
CkJsonObject_Dispose(header);