[ Pobierz całość w formacie PDF ]
.Program szyfruj;aaauses Crt, Strings;varaafin: file;aafout: file;aap: PChar;aazs: longint;aazr: longint;aalp: word;aalz: word;function kodujznak(c: char; klucz: byte): char;aavaraai: word;aaj: byte;beginaaj:=ord(c);aai:=j+klucz;aaif(j+klucz)>255 thenaaaaaaadec(i,255); {zmniejsza o 255}aakodujznak:=chr(i);end;function dekodujznak(c: char; klucz: byte): char;avaraai: word;aaj: byte;abeginaaj:=ord(c);aai:=j-klucz;aaif(j-klucz)<0 thenaaaaaaainc(i,255); {zwieksza o 255}aadekodujznak:=chr(i);end;procedure szyf(Co :Pchar; haslo: string);avaraai:longint;aab:byte;abeginaab:=1;aafor i:=0 to strlen(co)-1 doaabeginaaaaaaaco[i]:=kodujznak(co[i], ord(haslo[b]));aaaaaaainc(b); if b>length(haslo) then b:=1;aaend;end;procedure deszyf(Co :Pchar; haslo: string);avaraai:longint;aab:byte;abeginaab:=1;aafor i:=0 to strlen(co)-1 doaaabeginaaaaaaaco[i]:=dekodujznak(co[i], ord(haslo[b]));aaaaaaainc(b); if b>length(haslo) then b:=1;aaend;aend;{************ Poczatek glownego programu *****************}beginaaclrscr;aaassign(fin, paramstr(1));aaassign(fout, paramstr(2));aareset(fin,1);aarewrite(fout,1);aazs:=filesize(fin);aawhile zs>0 doaaabeginaaaaaaaazr:=maxavail-1024*3;aaaaaaaaif zr>65535 then zr:=65534;aaaaaaaaif zr>zs thenaaaaaaaaaaaaabeginaaaaaaaaaaaaaaaaaaazr:=zs;aaaaaaaaaaaaaaaaaaazs:=0;aaaaaaaaaaaaaaendaaaaaaaaelseaaaaaaaaaaaaazs:=zs-zr;aaaaaaaagetmem(p,zr);a aaaaaarepeataaaaaaaaaaaablockread(fin, P^, zr, lz);aaaaaaaaaaaaszyf(p,paramstr(3));{dla programu deszyfrujacego powyzsza linijkenalezy zamienic na: deszyf(p, paramstr(3));}aaaaaaaaaaaablockwrite(fout,p^,lz,lp);aaaaaaaauntil (lz=0) or (lp<>lz);aaaaaaaaif assigned(p) thenaaaaaaaaaaaaaaaafreemem(p,zr);aaaaend;aaclose(fin);aaclose(fout);end.{**************** Koniec programu *************************}
[ Pobierz całość w formacie PDF ]