Einzelnen Beitrag anzeigen

BrotherLui

Registriert seit: 14. Jun 2006
26 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: Vorschau und Öffnen von Bilddateien nicht zulassen

  Alt 16. Jun 2006, 14:56
Verschlüsselung. Das ist es!

Hab es mit XOR gelöst. Ist bestimmt nicht das Sicherste aber muss es in meinem Fall auch nicht sein.

Delphi-Quellcode:
function XORCrypt(Password,InputFilePath,OutputFilePath:String):Boolean;
var aktChar: Integer;
   InputFile, OutputFile: File of Byte;
   Buffer:Byte;
begin
  Result := False;

  try
    aktChar := 1;

    AssignFile(InputFile,InputFilePath);
    Reset(InputFile);

    AssignFile(OutputFile,OutputFilePath);
    Rewrite(OutputFile);

    while not Eof(InputFile) do
    begin
      if(aktChar > Length(Password)) then aktChar := 1;
      Read(InputFile,Buffer);
      Buffer := Buffer xor ord(Password[aktChar]);
      Write(OutputFile,Buffer);
      Inc(aktChar);
      Application.ProcessMessages;
    end;
  finally
    CloseFile(InputFile);
    CloseFile(OutputFile);

    Result := True;
  end;
end;

Danke!
  Mit Zitat antworten Zitat