Ich hatte mal genau das selbe problem und hab folgendes gemacht:
Delphi-Quellcode:
unit UClasses;
interface
uses IniFiles, UBase64, SysUtils;
type
{*****
TCryptedIniFile
Abgeleitet von TIniFile
XOR-Verschlüsselung
Passwort speichern
*****}
TCryptedIniFile =
class(TIniFile)
private
function Crypt(Value, Key:
String):
String;
public
function ReadPassword(Section:
String; Ident:
String;
Default:
String):
String;
procedure WritePassword(Section:
String; Ident:
String; Value:
String);
end;
implementation
function TCryptedIniFile.Crypt(Value, Key:
String):
String;
var a,b: integer;
begin
b:=1;
for a := 1
to Length(Value)
do
begin
Value[a]:=Chr(Ord(Value[a])
xor Ord(Key[b]));
inc(b);
if b > length(Key)
then b:=1;
end;
Result:=Value;
end;
function TCryptedIniFile.ReadPassword(Section:
String; Ident:
String;
Default:
String):
String;
var S:
String;
begin
S:=ReadString(Section,Ident,'
');
if S='
'
then
Result:=Default
else
Result:=Crypt(Crypt(Base64Decode(ReadString(Section,Ident,
Default)),Section),Ident);
end;
procedure TCryptedIniFile.WritePassword(Section:
String; Ident:
String; Value:
String);
begin
WriteString(Section,Ident,Base64Encode(Crypt(Crypt(Value,Section),Ident)));
end;
end.
wobei UBase64 die Base64-
Unit hier aus der CodeLib ist...
PS: wie sicher das ganze verschlüsselt ist: Keine Ahnung ^^