Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
MD4 Hash a String
See more Encryption Examples
MD4 hash a string.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.Crypt2;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
crypt: TCrypt2;
content: string;
hashStr: string;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
crypt := TCrypt2.Create;
content := 'The quick brown fox jumps over the lazy dog';
// The desired output is a hexidecimal string:
crypt.EncodingMode := 'hex';
// Set the hash algorithm:
crypt.HashAlgorithm := 'md4';
hashStr := crypt.HashStringENC(content);
WriteLn(hashStr);
// The output is:
// 1BEE69A46BA811185C194762ABAEAE90
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.