Sample code for 30+ languages & platforms
Delphi ActiveX

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 ActiveX Downloads

Delphi ActiveX
var
success: Integer;
jwe: TChilkatJwe;
jweCompact: WideString;
json: TChilkatJsonObject;

begin
success := 0;

jwe := TChilkatJwe.Create(Self);

//  Load the JWE.
jweCompact := 'eyJhbGciOiJBMjU2S1ciLCJlbmMiOiJBMjU2R0NNIn0.<...>.<iv>.<ciphertext>.<tag>';
success := jwe.LoadJwe(jweCompact);
if (success = 0) then
  begin
    Memo1.Lines.Add(jwe.LastErrorText);
    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 := TChilkatJsonObject.Create(Self);
success := jwe.GetHeader(json.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(jwe.LastErrorText);
    Exit;
  end;

json.EmitCompact := 0;
Memo1.Lines.Add(json.Emit());