Registriert seit: 10. Jun 2004
Ort: Garching (TUM)
4.579 Beiträge
|
Re: "Verschlüsselte" Bilddateien "entschlüsse
26. Okt 2008, 14:02
Hallo, versuche doch mal diesen Code, um die MD5-Hashs zu ersetzen:
Delphi-Quellcode:
type
MD5Digest: Array [0..15] of byte
type
MD5Digest: Array [0..15] of byte
procedure Replace(Stream: TStream; oldmd5, newmd5: MD5Digest)
var
i: Integer;
pos: Int64;
pattern: MD5Digest;
begin
for i = 0 to 15 do
begin
oldmd5[i] := oldmd5[i] xor $8D;
newmd5[i] := newmd5[i] xor $8D;
end;
Stream.Position := 0;
while (Stream.size - Stream.Position) >= sizeof(MD5Digest) do
begin
pos := Stream.Position;
Stream.readbuffer(pattern, sizeof(MD5Digest));
Stream.position = pos + 1; // Wir müssen byteweise vorgehen
if (comparemem(@pattern[0], @oldmd5[0], sizeof(MD5Digest)) = 0) then
begin
Stream.position = pos;
Stream.writeBuffer(newmd5, sizeof(MD5Digest));
break;
end;
end;
end;
procedure ReplaceFile(FileName: String; old, new: Array of MD5Digest)
var
fs: TFileStream;
mem: TmemoryStream;
i: Integer;
begin
mem := TMemoryStream.Create();
fs := TFileStream.Create(FileName, fmOpenReadWrite or fmShareExclusive);
try
mem.CopyFrom(fs, 0);
for i = low(old) to high(old) do
begin
Replace(mem, old[i], new[i]);
end;
fs.CopyFrom(mem, 0);
finally
fs.Free;
mem.Free;
end;
end;
So ähnlich zumndest
|
|
Zitat
|