[...]
type
TDecodeThread =
class(TThread)
private
{ Private-Deklarationen }
public
FFilename:
string;
FPW:
string;
function DecodeFile(sFileName, sPassword:
string): Boolean;
protected
procedure Execute;
override;
end;
[...]
implementation
[...]
procedure TDlgDatenTransferIntern.MPFeuerImport;
var
DThread : TDecodeThread;
sPassword, sFilename :
string;
[...]
begin
[...]
//Thread aufruf
DThread := TDecodeThread.Create(True);
DThread.Priority := tpNormal;
DThread.FreeOnTerminate := True;
DThread.FFilename := sFilename;
DThread.FPW := sPassword;
DThread.Resume;
WaitForSingleObject(DThread.Handle, INFINITE);
[...]
end;
function TDecodeThread.DecodeFile(sFileName, sPassword:
string): Boolean;
var
Blowfish : TlbBlowfish;
begin
if FileExists(COPY(sFileName, 1, Length(sFileName)-4)+'
.FDB')
then
DeleteFile(COPY(sFileName, 1, Length(sFileName)-4)+'
.FDB');
Blowfish := TlbBlowfish.Create(
nil);
Blowfish.GenerateKey(UpperCase(sPassword));
Blowfish.DecryptFile(COPY(sFileName, 1, Length(sFileName)-4)+'
.BLF', COPY(sFileName, 1, Length(sFileName)-4)+'
.FDB');
Blowfish.Free;
end;
procedure TDecodeThread.Execute;
var
HashDecodedFile:
string;
begin
if not DecodeFile(FFilename, FPW)
then
Messagebox(
Handle, '
Fehler beim Entschlüsseln der Datei.',
'
Datei entschlüsseln', MB_ICONSTOP);
end;