Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
DSA Public Key PEM to DER Conversion
See more DSA Examples
Converts a DSA public key from PEM format to DER.Chilkat Pascal (Lazarus/Delphi) Downloads
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;
pemPublicKey: 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 PEM public key.
pemPublicKey := dsa.LoadText('dsa_pub.pem');
// Import the public key PEM into the DSA object.
success := dsa.FromPublicPem(pemPublicKey);
if (success <> True) then
begin
WriteLn(dsa.LastErrorText);
Exit;
end;
// Write it out as a DER file:
success := dsa.ToPublicDerFile('dsa_pub.der');
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.