MR_BEN
Ученик
Здравствуйте, пользователи P-I. Мне очень нужна помощь людей, знающих паскаль.
Смотрите:
Мне нужно создать decrypt, противоположной encrypt.
Кто может, помогите!
Смотрите:
PHP:
Program Spyware;
const BuffSize=108544;
N=2;
M=255;
type Byte_data = array [0..BuffSize] of byte;
const table: array [0..M] of byte = (225,22,193,19,170,136,150,220,66,194,5,248,89,81,137,61,84,199,4,111,125,117,159,44,250,188,64,162,246,118,34,68,145,107,
216,86,158,238,124,215,3,74,97,77,35,148,153,29,151,8,172,42,32,173,141,213,197,202,174,65,245,177,39,176,7,10,47,223,38,
116,166,182,95,228,85,209,187,244,233,186,129,41,114,178,90,71,101,171,234,210,122,98,59,207,191,131,154,160,53,23,108,70,
33,54,83,104,181,25,152,106,121,203,126,6,179,87,235,132,94,43,133,99,242,0,63,62,236,9,17,222,239,167,49,55,139,157,138,
237,163,31,78,143,204,241,219,230,195,15,168,113,135,76,254,75,20,93,229,103,175,249,28,189,217,185,240,12,232,200,14,80,
128,48,147,211,212,45,16,224,46,183,155,196,252,36,205,27,243,73,18,96,52,120,165,218,184,30,13,227,123,255,134,130,214,58,
56,21,110,37,105,82,144,140,119,208,115,67,51,40,92,24,72,1,161,231,198,109,100,57,206,169,226,60,146,69,102,221,2,156,26,
192,142,149,190,253,180,91,112,50,79,88,251,127,247,201,11,164);
////////////////////////////////////////////
var data: Byte_data;
i: longint;
fileSize: longint;
cypherFile: file of byte;
b: byte;
source_file, smth: string;
//////////////
label the_end;
////////////////////////////////////////////
procedure encrypt(var data:Byte_data; n:longint; key: string);
var i,m: longint;
begin
m:=length(key);
for i:=0 to n do
begin
data[i]:=table[data[i]];
data[i]:=data[i] xor ord(key[i mod m+1]);
end;
end;
procedure decrypt(
Begin
if ParamCount=0 then
begin writeln('No parameters. Program demands 2 parameters: file and mode');
goto the_end;
end;
source_file:=ParamStr(1);
smth:=source_file;
assign(cypherFile,source_file);
reset(cypherFile);
//reading from file
i:=0;
while not eof(cypherFile) do
begin
read(cypherFile,b);
data[i]:=b;
i:=i+1;
end;
fileSize:=i;
close(cypherFile);
if ParamStr(2)='encrypt'
then
begin
//encryption data
encrypt(data,fileSize,smth);
//write cyphering file
assign(cypherFile,'cryptedFile');
rewrite(cypherFile);
for i:=0 to fileSize-1 do
write(cypherFile,data[i]);
close(cypherFile);
end
else
if ParamStr(2)='decrypt'
then
begin
//decryption data
decrypt( //part of code is absent
//write decrypted file
assign(cypherFile,'decryptedFile');
rewrite(cypherFile);
for i:=0 to fileSize-1 do
write(cypherFile,data[i]);
close(cypherFile);
end
else writeln('Invalid parameters. Mode parameters may be only encrypt or decrypt!');
the_end:
End.
Кто может, помогите!
