Sample code for 30+ languages & platforms
Lazarus Pascal

Example: Crypt2.CrcBd method

Demonstrates how to call the CrcBd method.

Chilkat Lazarus Pascal Downloads

Lazarus Pascal
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.BinData,
  Chilkat.Crypt2;

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

procedure RunDemo;
var
  crypt: TCrypt2;
  bd: TBinData;
  crc32: LongWord;
  crc8: LongWord;

begin
  crypt := TCrypt2.Create;

  bd := TBinData.Create;
  bd.AppendString('123456789','us-ascii');

  crc32 := crypt.CrcBd('crc-32',bd);
  //  The decimal value is 3421780262 (converted to hex is 0xCBF43926)
  WriteLn(crc32);

  crc8 := crypt.CrcBd('crc8',bd);
  WriteLn(crc8);


  crypt.Free;
  bd.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.