Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

Compress EBICS SignaturePubKeyOrderData XML

See more EBICS Examples

This example provides a note about how to compress the SignaturePubKeyOrderData XML for EBICS.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.Compression,
  Chilkat.FileAccess;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  fac: TFileAccess;
  strXml: string;
  compress: TCompression;
  b64CompressedStr: string;

begin
  //  This example assumes the Chilkat API to have been previously unlocked.
  //  See Global Unlock Sample for sample code.

  //  We have this XML to be compressed and then encoded in Base64.

  //  <?xml version="1.0" encoding="UTF-8"?>
  //  <SignaturePubKeyOrderData xmlns="http://www.ebics.org/S001" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ebics.org/S001 http://www.ebics.org/S001/ebics_signature.xsd">
  //  <SignaturePubKeyInfo>
  //  <ds:X509Data>
  //  <ds:X509IssuerSerial>
  //  <ds:X509IssuerName>ABCDEF eID User</ds:X509IssuerName>
  //  <ds:X509SerialNumber>153594950300874710199347185895388116050</ds:X509SerialNumber>
  //  </ds:X509IssuerSerial>
  //  <ds:X509Certificate>MIIJTzCC...xzKyukE=</ds:X509Certificate>
  //  </ds:X509Data>
  //  <PubKeyValue>
  //  <ds:RSAKeyValue><ds:Modulus>zedQEG0gNItQRG17p7CwiSv/N9YUBOzswEnfNSiNirQgb0bfWWAvCXOg7057WTCBMxOe7AHE7rLTTQFRHY2AEqSV1fj8iL7i186XnGQOFjsdVP3LBLV319HhoUIugaZOC5AbnDouq2Femr53NDK4fqYVI6skrvNo9LO4+8IBRNtR8lQudG+ABHCqIkrNjai1pXrjfEhvyAhz0URhqP00i3AUGD3BasM28uFhcNztqSfO/jp5xQOTAjSr2gCgwg9hJV5mVnOazwAEbWmKkW+NZGICrSdoyrJ+UKjbbhL6VI1woe2YufCYqYF0ec8bXdE9KlhHj+XjeaME3k/uBq22Kw==</ds:Modulus><ds:Exponent>AQAB</ds:Exponent></ds:RSAKeyValue>
  //  <TimeStamp>2015-03-06T18:42:24.376+01:00</TimeStamp>
  //  </PubKeyValue>
  //  <SignatureVersion>A005</SignatureVersion>
  //  </SignaturePubKeyInfo>
  //  <PartnerID>XKB99999</PartnerID>
  //  <UserID>XKB99999</UserID>
  //  </SignaturePubKeyOrderData>  

  fac := TFileAccess.Create;
  strXml := fac.ReadEntireTextFile('qa_data/ebics/SignaturePubKeyOrderData.xml','utf-8');
  //  Assuming the above statement succeeded...

  compress := TCompression.Create;

  //  EBICS wants the deflate algorithm with the zlib header...
  compress.Algorithm := 'zlib';
  compress.EncodingMode := 'base64';

  b64CompressedStr := compress.CompressStringENC(strXml);

  WriteLn(b64CompressedStr);


  fac.Free;
  compress.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.