Sample code for 30+ languages & platforms
Lazarus Pascal

Example: Crypt2.AddPfxSourceFile method

Demonstrates how to call the AddPfxSourceFile method.

Chilkat Lazarus Pascal Downloads

Lazarus Pascal
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.Crypt2;

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

procedure RunDemo;
var
  success: Boolean;
  crypt: TCrypt2;
  pfxPath: string;
  pfxPassword: string;

begin
  success := False;

  crypt := TCrypt2.Create;
  success := False;

  //  Do public-key decryption (RSA)
  crypt.CryptAlgorithm := 'pki';

  //  ...
  //  ...
  //  ...

  pfxPath := 'c:/my_pfx_files/a.pfx';
  pfxPassword := 'secret1';
  success := crypt.AddPfxSourceFile(pfxPath,pfxPassword);
  if (success = False) then
    begin
      WriteLn(crypt.LastErrorText);
      Exit;
    end;

  //  Add as many as PFX sources as desired...
  pfxPath := 'c:/my_pfx_files/b.pfx';
  pfxPassword := 'secret2';
  success := crypt.AddPfxSourceFile(pfxPath,pfxPassword);
  if (success = False) then
    begin
      WriteLn(crypt.LastErrorText);
      Exit;
    end;

  //  ...
  //  ...


  crypt.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.