Delphi ActiveX
Delphi ActiveX
Get the JWS Payload into BinData
See more JSON Web Signatures (JWS) Examples
Demonstrates Jws.GetPayloadBd, which writes the payload of a loaded JWS as raw bytes into a BinData.
Background. This is used when the payload is binary. In practice, validate the signature before trusting the payload.
Chilkat Delphi ActiveX Downloads
var
success: Integer;
jws: TChilkatJws;
jwsCompact: WideString;
bdPayload: TChilkatBinData;
begin
success := 0;
jws := TChilkatJws.Create(Self);
// Load the JWS compact serialization.
jwsCompact := 'eyJhbGciOiJIUzI1NiJ9.VGhpcyBpcyB0aGUgY29udGVudCB0byBzaWduLg.<signature>';
success := jws.LoadJws(jwsCompact);
if (success = 0) then
begin
Memo1.Lines.Add(jws.LastErrorText);
Exit;
end;
// Get the JWS payload as raw bytes into a BinData.
bdPayload := TChilkatBinData.Create(Self);
success := jws.GetPayloadBd(bdPayload.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(jws.LastErrorText);
Exit;
end;
Memo1.Lines.Add('Payload is ' + IntToStr(bdPayload.NumBytes) + ' bytes.');