Program Kriptografi Substitusi
program kripto;
uses crt;
var
f1,f2 :text;
p:char;
c:integer;
d:string[99];
namafile:string[99];
kunci:integer;
begin
clrscr;
writeln('=======================================================');
writeln('Ini adalah program kriptografi substitusi');
writeln('Masukkan nama file yang akan di buat?');
writeln('Contoh: D\sigit.txt');readln(namafile);
writeln('=======================================================');
writeln('Masukkan isi dari file yang akan di cipher substitusi :');readln(d);
assign(f1,namafile);
rewrite(f1);
writeln(f1,d);
reset(f1);
assign(f2,'chipher.txt');
rewrite(f2);
write('Masukkan angka kunci ciphertex=');readln(kunci);
write('Lihat hasilnya pada file CHIPHER.TXT');readln;
while not EOF(f1) do
begin
while not EOLN(f1) do
begin
read(f1, p);
c:=(ord(p) + kunci) mod 256;
write(f2, chr(c));
end;
readln(f1);
writeln(f2);
end;
close(f1);
close(f2);
end.
0 komentar:
Posting Komentar