I\'m trying to protect a local database that contains sensitive info (similar to this question, only for delphi 2010)
I\'m using DI
Ok, here's an example using TurboPower Lockbox (version 2)
uses LbCipher, LbString;
TaAES = class
private
Key: TKey256;
FPassword: string;
public
constructor Create;
function Code(AString: String): String;
function Decode(AString: String): String;
property Password: string read FPassword write FPassword;
end;
function TaAES.Code(AString: String): String;
begin
try
RESULT := RDLEncryptStringCBCEx(AString, Key, SizeOf(Key), False);
except
RESULT := '';
end;
end;
constructor TaAES.Create;
begin
GenerateLMDKey(Key, SizeOf(Key), Password);
end;
function TaAES.Decode(AString: String): String;
begin
RESULT := RDLEncryptStringCBCEx(AString, Key, SizeOf(Key), True);
end;
You can save your password as variable in your application. Without save to file example but you can use TFileStream to save encrypted(code) password and then decode it to read it :-)