
12.01.2010, 12:05
|
|
Познающий
Регистрация: 28.01.2009
Сообщений: 90
С нами:
9096406
Репутация:
80
|
|
на Delphi
Код:
{кодирование информации}
function CodeString(Text: ansistring; EncodeFile: string; key: string): ansistring;
var
data: file of char;
mykey: ansistring;
i,k,f : integer;
c: char;
begin
AssignFile(data,EncodeFile);
Rewrite(data);
for i := 0 to (length(text) div length(key)) do
mykey := mykey+key;
for i := 1 to length(text) do begin
c := chr(byte(text[i]) XOR byte(mykey[I]));
Write(data,c);
Result:=result+c;
end;
CloseFile(data);
end;
{Декодирование информации}
function DeCodeString(Decodefile: string; key: string): ansistring;
var
Idata: file of char;
mykey: ansistring;
i,k,f : integer;
c: char;
begin
AssignFile(Idata,Decodefile);
Reset(Idata);
i:=1;
f:=FileSize(Idata);
for i := 0 to (f div length(key)) do
mykey := mykey+key;
for i:=1 to f do begin
Read(Idata,c);
c := (chr(byte(c) XOR byte(mykey[I])));
Result:=result+c;
end;
CloseFile(Idata);
end;
|
|
|