unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
TGTR2SaveGameInfo =
record
Player:
String;
Time:
String;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
DECHash, DECCipher, DECFmt;
function GTR2Decode(AInput:
string):
string;
var
hash: THash_MD5;
cipher: TCipher_3DES;
tmp_md5, tmp_output:
string;
const
Secret = '
Gtr2Manager';
begin
// DEC Initialisierung
SetDefaultCipherClass(TCipher_3DES);
SetDefaultHashClass(THash_MD5);
// 1. Compute hash of key (Gtr2Manager)
hash := THash_MD5.Create;
try
tmp_md5 := hash.CalcBinary(Secret, TFormat_Copy);
// WELCHES FORMAT???
finally
hash.free;
end;
// 2. Use TripleDES ECB to decrypt data using computed key.
cipher := TCipher_3DES.Create;
try
cipher.Mode := cmECBx;
cipher.Init(tmp_md5);
cipher.Decode(AInput, tmp_output, length(AInput));
// Dicke AccessViolation
UniqueString(tmp_output);
// Notwendig?
finally
cipher.free;
end;
result := tmp_output;
end;
function GTR2ReadSaveGame(AFilename:
string): TGTR2SaveGameInfo;
var
txt: TextFile;
tmp_player, tmp_time:
string;
begin
AssignFile(txt, AFilename);
Reset(txt);
ReadLn(txt, tmp_player);
result.Player := GTR2Decode(tmp_player);
ReadLn(txt, tmp_time);
result.Time := GTR2Decode(tmp_time);
CloseFile(txt);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sav: TGTR2SaveGameInfo;
begin
sav := GTR2ReadSaveGame('
C:\SaveGame.sav');
showmessage('
Player=' + sav.Player);
showmessage('
Time=' + sav.Time);
end;
end.