Delphi DLL
Delphi DLL
Get the JWE Protected Header
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.GetProtectedHeader, which copies the decoded shared JWE protected header into a JsonObject.
Background. Only the protected header is returned; it is not merged with the shared unprotected header or any per-recipient header.
Chilkat Delphi DLL Downloads
var
success: Boolean;
jwe: HCkJwe;
jweCompact: PWideChar;
json: HCkJsonObject;
begin
success := False;
jwe := CkJwe_Create();
// Load the JWE.
jweCompact := 'eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>';
success := CkJwe_LoadJwe(jwe,jweCompact);
if (success = False) then
begin
Memo1.Lines.Add(CkJwe__lastErrorText(jwe));
Exit;
end;
// Copy the decoded shared JWE protected header into a JsonObject. Only the protected header is
// returned; it is not merged with the unprotected or per-recipient headers.
json := CkJsonObject_Create();
success := CkJwe_GetProtectedHeader(jwe,json);
if (success = False) then
begin
Memo1.Lines.Add(CkJwe__lastErrorText(jwe));
Exit;
end;
CkJsonObject_putEmitCompact(json,False);
Memo1.Lines.Add(CkJsonObject__emit(json));
CkJwe_Dispose(jwe);
CkJsonObject_Dispose(json);