Autor Beitrag
newbie44
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 117

Windows XP, Windows ME
D6 Pers, D7 Enterprise
BeitragVerfasst: Do 12.08.04 18:03 
Hallo,

ich habe ein Problem ich habe eine Funktion gefunden, von der ich nicht weiß was sie genau macht. Ich wäre euch dankbar, wenn Ihr mir diese gut erklären könntet:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Stream.LoadFromFile(Filename);
    Stream.Position := 0;
    Data := Stream.Memory;
    for Loop := 0 to (Stream.Size div 4) + 1 do
    begin
      Data^ := Data^ xor $00000F7E;
      Inc(Data);
    end;
  except
    Stream.Position := 0;
    Stream.Size := 0;
    Result := False;
  end;
end;


Dankeschön schon im Vorraus

Sebby :(

_________________
Dumm darf man sein, aber zu helfen muss man sich wissen.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Do 12.08.04 18:14 
Wenn ich das richtig sehe, dann wird die Datei mit $F7E gexort:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Stream.LoadFromFile(Filename); // Stream ist vom Typ TMemoryStream?
    Stream.Position := 0;
    Data := Stream.Memory;   // Zeiger auf den Anfang der Daten
    for Loop := 0 to (Stream.Size div 4) + 1 do   // Die Daten in 4-Byte Blöcke aufteilen
    begin
      Data^ := Data^ xor $00000F7E;    // Jeden Block einlesen und mit $F7E Suche in der Entwickler-Ecke XOR IN DF, DLen
      Inc(Data);    // Zeiger um vier erhöhen, um den nächsten Block zu xoren
    end;
  except   // falls ein Fehler auftritt
    Stream.Position := 0;    // Position zurücksetzen
    Stream.Size := 0;   // Größe  -"-
    Result := False;   // - ohne Worte -
  end;
end;

Wenn man so will, wird die Datei "ent-" bzw. "verschlüsselt".

raziel

_________________
JSXGraph
newbie44 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 117

Windows XP, Windows ME
D6 Pers, D7 Enterprise
BeitragVerfasst: Do 12.08.04 18:22 
Hi,

danke für die Erklärung. Aber was genau macht jetzt xor?

In der Hilfe habe ich zwar was darüber gefunden, kann damit leider nix anfangen.

Gruß

Sebby :gruebel:

_________________
Dumm darf man sein, aber zu helfen muss man sich wissen.
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Do 12.08.04 18:24 
Suche in: Delphi-Forum, Delphi-Library XOR ist eine sehr simple Verschlüsslungsmethode. Darüber gab's hier schon sooo oft Fragen.

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
newbie44 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 117

Windows XP, Windows ME
D6 Pers, D7 Enterprise
BeitragVerfasst: Do 12.08.04 18:42 
Ich habe noch eine Funktion gefunden. Was macht denn jetzt diese?

Bin für jede Erklärung dankbar

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Source.LoadFromFile(Filename);
     Stream.Clear;
     Index := 1;
     while Source.Read(Value, SizeOf(Value)) = SizeOf(Value) do
     begin
       Value := Value xor $00000F7E;
       Stream.WriteBuffer(Value, SizeOf(Value));
       Inc(Index);
       if Index = $1000 then
       begin
         if Source.Read(Value, SizeOf(Value)) <> SizeOf(Value) then
           Break;
         Index := 1;
       end;
     end;
     Result := True;
   finally
     Source.Free;


Gruß

Sebby :roll:

_________________
Dumm darf man sein, aber zu helfen muss man sich wissen.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 12.08.04 21:02 
Das gleiche, wie die obrige Funktion, AUSSER dass sie alle 16 KB ($1000 * 4 Bytes) einen Integer (4 Byte) auslässt.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.