Sample code for 30+ languages & platforms
Delphi DLL

Get the Entire Loaded JWE Structure

See more JSON Web Encryption (JWE) Examples

Demonstrates Jwe.GetHeader, which copies the entire currently loaded JWE structure into a JsonObject.

Background. This is the full JWE representation, not a decoded or merged JOSE header. It can contain the protected, unprotected, and per-recipient header material.

Chilkat Delphi DLL Downloads

Delphi DLL
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 entire loaded JWE structure into a JsonObject.  This is the full JWE representation, not a
//  decoded or merged JOSE header.
json := CkJsonObject_Create();
success := CkJwe_GetHeader(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);