Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Compute Glacier SHA256 Linear Hash of a File
See more Amazon Glacier Examples
Computes the Amazon Glacier SHA256 linear hash for a file.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;
linearHashHex: string;
begin
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
crypt := TCrypt2.Create;
// The "linear hash" is simply the SHA256 hash of the file bytes.
crypt.HashAlgorithm := 'sha256';
// Return the hash in lowercase hexidecimal format.
crypt.EncodingMode := 'hexlower';
linearHashHex := crypt.HashFileENC('qa_data/jpg/penguins.jpg');
WriteLn('SHA256 linear hash = ' + linearHashHex);
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.