Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Load an Ed25519 Key from Raw Hex
See more Private Key Examples
Demonstrates the Chilkat PrivateKey.LoadEd25519 method, which loads an Ed25519 key pair from raw hexadecimal. The first argument is the 32-byte private seed and the second is the 32-byte public key. Each nonempty value must be exactly 64 hexadecimal digits.
Background: Ed25519 keys are compact fixed-size byte strings rather than the structured ASN.1 of RSA, so raw hex is a natural way to carry them. This loader takes the 32-byte seed (from which the full private key is derived) and the 32-byte public key directly, which is useful when a key originates from a system that emits raw values rather than a PEM or JWK container. For a standard container, use one of the PEM/PKCS #8/JWK loaders instead.
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.PrivateKey;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
privKey: TPrivateKey;
privSeedHex: string;
pubKeyHex: string;
begin
success := False;
// Demonstrates the PrivateKey.LoadEd25519 method, which loads an Ed25519 key pair from raw
// hexadecimal. The 1st argument is the 32-byte private seed and the 2nd is the 32-byte public
// key. Each nonempty value must be exactly 64 hexadecimal digits.
privKey := TPrivateKey.Create;
// The 32-byte Ed25519 private seed and public key, each as 64 hex digits.
privSeedHex := '9d61b19deffkbfa4ffa4d8c8f8a5b4a3d9e8c7b6a5f4e3d2c1b0a9f8e7d6c5b4';
pubKeyHex := 'd75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a';
success := privKey.LoadEd25519(privSeedHex,pubKeyHex);
if (success = False) then
begin
WriteLn(privKey.LastErrorText);
Exit;
end;
WriteLn('Loaded an Ed25519 private key.');
privKey.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.