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

Convert DSA Public Key DER to PEM

See more DSA Examples

Converts a DSA public key from DER format to PEM.

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.Dsa;

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

procedure RunDemo;
var
  success: Boolean;
  dsa: TDsa;
  pemStr: string;

begin
  success := False;

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

  dsa := TDsa.Create;

  //  Load a DER public key.
  success := dsa.FromPublicDerFile('dsa_pub.der');
  if (success <> True) then
    begin
      WriteLn(dsa.LastErrorText);
      Exit;
    end;

  //  Save the public key to PEM:
  pemStr := dsa.ToPublicPem();
  success := dsa.SaveText(pemStr,'dsa_pub.pem');
  if (success <> True) then
    begin
      WriteLn(dsa.LastErrorText);
      Exit;
    end;

  WriteLn('Finished!');


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