Sample code for 30+ languages & platforms
Lazarus Pascal

Example: Crypt2.DecodeString method

Demonstrates how to call the DecodeString 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.Crypt2;

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

procedure RunDemo;
var
  crypt2: TCrypt2;
  encodedStr: string;
  encoding: string;
  charset: string;
  str: string;

begin
  crypt2 := TCrypt2.Create;

  //  The string "Hello World" in base64 (using the utf-8 byte representation) is "SGVsbG8gV29ybGQ="

  encodedStr := 'SGVsbG8gV29ybGQ=';
  encoding := 'base64';
  charset := 'utf-8';

  str := crypt2.DecodeString(encodedStr,charset,encoding);
  WriteLn(str);

  //  Output is "Hello World"


  crypt2.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.