[fpc-pascal] Re: encryption and decryption

leledumbo leledumbo_cool at yahoo.co.id
Sun Jun 24 16:59:36 CEST 2012


For examples, I think it's better to use the data type wrapper of the
Read/Write, instead of using the low level methods:

{$mode objfpc}{$H+}

uses classes,blowfish;

var
  en: TBlowFishEncryptStream;
  de: TBlowFishDeCryptStream;
  s1,s2: TStringStream;
  key,value,temp: String;
begin
  key := 'testkey';
  value := 'this is a string';

  s1 := TStringStream.Create('');
  en := TBlowFishEncryptStream.Create(key,s1);
  en.WriteAnsiString(value);
  en.Free;

  WriteLn('encrypted: ' + s1.DataString);

  s2 := TStringStream.Create(s1.DataString);
  s1.Free;

  de := TBlowFishDeCryptStream.Create(key,s2);

  temp := de.ReadAnsiString;
  WriteLn('decrypted: ' + temp);

  de.Free;
  s2.Free;
end. 

--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/encryption-and-decryption-tp5710131p5710147.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list