V
V
vikatkachyk2018-12-23 15:33:30
Encryption
vikatkachyk, 2018-12-23 15:33:30

Error in the text of the Vigenère encryption program in Pascal?

When compiling on line 130, it gives this error:
Vizhiner2.pas(130) : The type of the parameter or return value cannot be a record description or an array description with bounds.

spoiler
program vizhiner2;
uses crt, graphABC;
const

 alphabet='АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'+'АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ';
  alphabet2='АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ';
  sym = ' .АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'+'абвгдеёжзийклмнопрстуфхцчшщъыьэюя';


var
  s0,s1,s2: string;
  tablchar:array [1..34]  of char;
  keyword,key_out:string;
  t:text;
  i,j,k,o,rec:integer;
  str,stol:char;
 arr_key, arr_mass,arr_demass,r,m:  array[0..200] of integer;
procedure Encrypt(str_massage: string; str_key: string; var es:string; var arr_of_n_key, arr_of_n_mass:array  of integer ;i:integer; var str_key_out: string);
var
  es2:string;
  l_massage,l_alph,l_keyword,n_mass,k: integer;
  n_key,y: integer;
  sym_massage,sym_key:char;
begin
  l_massage:=length(str_massage);
  write('l_massage=',l_massage);
    readln;
  l_alph:=length(sym);
  write('l_alph=',l_alph);
    readln;
    l_keyword:=length(keyword);
  write('l_keyword=',l_keyword);
    readln;
  es:=str_massage;
  es2:=str_key;
  writeln('es=',str_massage);
  writeln('es2=',str_key);
  write('начало шифрования');
    readln;

  for i:=1 to l_massage do begin
    y:=y+1;
    writeln('y=',y);
    writeln('итеррация ',i);
  writeln('es=',str_massage);
  writeln('es2=',str_key);
    sym_massage:=str_massage[i];
    writeln('sym_mass=',sym_massage);
    n_mass:=pos(sym_massage,sym);
    writeln('no_mass=',n_mass);
    for k:=y to l_keyword do
    begin
    writeln('внутренняя итеррация ',k);
    sym_key:=str_key[k];
    writeln('sym_key=',sym_key);
    n_key:=pos(sym_key,sym);
    writeln('no_key=',n_key);
    break;
    end;

  if n_mass=1 then
  n_mass:=1 else
  if n_mass=2 then
  n_mass:=2
  else
  if (n_mass>2) and (n_mass<36) then
  begin
  str_key_out[i]:=sym[n_key];
    writeln('str_key_out!!!!!!!!!!!!=',str_key_out[i]);
  n_key:=n_key-35;
  arr_of_n_key[i]:=n_key;///////////////накапливание массива с номерами букв ключевого слова

  writeln('n_key=',n_key);
  writeln('sym_key=', sym[n_key+2]);
  n_mass:=n_mass+n_key mod l_alph;
  arr_of_n_mass[i]:=n_mass;
  writeln ('n_mass=',n_mass);
  if n_mass>35 then
  n_mass:=n_mass-35+2;
  arr_of_n_mass[i]:=n_mass;
  writeln('n_mass=',n_mass)
  end
  else
  writeln('n_mass=',n_mass);
  if (n_mass>35) and (n_mass<l_alph+1) then
  begin
  str_key_out[i]:=sym[n_key];
    writeln('str_key_out!!!!!!!!!!!!=',str_key_out[i]);
    n_key:=n_key-35;
    arr_of_n_key[i]:=n_key;

    writeln('n_key=', n_key);
    writeln('sym_key=', sym[n_key]);
    n_mass:=n_mass+n_key mod l_alph;
    writeln('n_mass=',n_mass);
    arr_of_n_mass[i]:=n_mass;
    writeln('sym_mass=', sym[n_mass]);

    if n_mass>l_alph then
    begin
    n_mass:=n_mass-33;
    arr_of_n_mass[i]:=n_mass;
    end;
    end;
    writeln('no_mass=',n_mass);
    if y>=l_keyword then y:=0;
    es[i]:=sym[n_mass];

    writeln('es=',es[i]);
    writeln('arr_key=',arr_of_n_key[i]);
    writeln('arr_mass=',arr_of_n_mass[i]);
    writeln('KEY_OUT!!!!!!!!!!!!!=',str_key_out[i]);
    //writeln('STR_KEY=',str_key[i]);
    
    readln;

  end;
  for i:=1 to  l_massage do begin
    write(str_key_out[i]);
    end;
    writeln(' ');
  
   for i:=1 to  l_massage do begin
  if (arr_of_n_mass[i]>35) and (arr_of_n_mass[i]<l_alph+1) then
    arr_of_n_mass[i]:= arr_of_n_mass[i]-33   ;
         end;
         end;
         
         
procedure Decrypt(str_massage: string; str_key: string; var ds:string;var arr_of_n_key, arr_of_n_demass:array[0..200] of integer ;i:integer);
var
 ds2:string;
   l_massage,l_alph,l_keyword,n_mass,k: integer;
   n_key,y: integer;
  sym_massage,sym_key:char;
begin
  l_massage:=length(str_massage);
  write('l_massage=',l_massage);
    readln;
  l_alph:=length(sym);
  write('l_alph=',l_alph);
    readln;
    l_keyword:=length(keyword);
  write('l_keyword=',l_keyword);
    readln;
  ds:=str_massage;
  ds2:=str_key;
  writeln('es=',str_massage);
  writeln('es2=',str_key);
  write('начало дешифрования');
    readln;
    y:=0;
  for i:=1 to l_massage do begin
    y:=y+1;
    writeln('y=',y);
    writeln('итеррация ',i);
  writeln('es=',str_massage);
  writeln('es2=',str_key);
    sym_massage:=str_massage[i];
    writeln('sym_mass=',sym_massage);
    n_mass:=pos(sym_massage,sym);
    writeln('no_mass=',n_mass);


    for k:=y to l_keyword do
    begin
    writeln('внутренняя итеррация ',k);
    sym_key:=str_key[k];
    writeln('sym_key=',sym_key);
    n_key:=pos(sym_key,sym);
    writeln('no_key=',n_key);
    break;
    end;
  if n_mass=1 then
  n_mass:=1 else
  if n_mass=2 then
  n_mass:=2
  else
  if (n_mass>2) and (n_mass<36) then
  begin
  n_key:=n_key-35;
  arr_of_n_key[i]:=n_key;
  writeln('n_key=',n_key);
  writeln('sym_key=', sym[n_key+2]);
  n_mass:=n_mass-n_key mod l_alph;
  arr_of_n_demass[i]:=n_mass;
  writeln ('n_mass=',n_mass);
  if n_mass<3 then
  n_mass:=n_mass+35-2;
  arr_of_n_demass[i]:=n_mass;

  writeln('n_mass=',n_mass)
  end
  else
  writeln('n_mass=',n_mass);
  if (n_mass>35) and (n_mass<l_alph+1) then
  begin
    n_key:=n_key-35;
    arr_of_n_key[i]:=n_key;
    writeln('n_key=', n_key);
    writeln('sym_key=', sym[n_key+2]);
    n_mass:=n_mass-n_key mod l_alph;
    writeln('n_mass=',n_mass);
    arr_of_n_demass[i]:=n_mass;
    writeln('sym_mass=', sym[n_mass]);

    if n_mass<36 then
    begin
    n_mass:=n_mass+33;
    arr_of_n_demass[i]:=n_mass;
    end;
    end;
    writeln('no_mass=',n_mass);
    if y>=l_keyword then y:=0;
    ds[i]:=sym[n_mass];

    writeln('es=',ds[i]);
    readln;
  end;
  for i:=1 to  l_massage do begin
  if (arr_of_n_demass[i]>35) and (arr_of_n_demass[i]<l_alph+1) then
    arr_of_n_demass[i]:= arr_of_n_demass[i]-33;
         end;
         end;
begin
setwindowsize(1300,700);
  write('Введите сообщение: '); readln(s0);
  write('введите ключевое слово: '); readln(keyword);
  write('Шифрация ');

  readln;
     i:=0;
  Encrypt(s0,keyword,s1,arr_key,arr_mass,k,key_out);
  writeln(s1);
  for i:=1 to length(s0) do
  begin
  write(key_out[i]);
  end;
  

  readln;
  write('Дешифрация ');
  Decrypt(s1,keyword,s2,arr_key,arr_demass,k);
  writeln('Лешифрованное слово:',s0);
  readln;

  clrscr;
  for i:=1 to length(s0) do

  begin
  TextOut(20,20,inttostr(round(length(s0)/length(keyword))));
  rec:=50*i;
  SetFontColor(clblack);
  SetFontSize(20);
  rectangle(50+rec,50,100+rec,100);
  TextOut(65+rec,57,s0[i]);
  rectangle(50+rec,100,100+rec,150);
  TextOut(65+rec,107,inttostr (arr_demass[i]-2));
  rectangle(50+rec,150,100+rec,200);
  TextOut(65+rec,157,key_out[i]);
  rectangle(50+rec,200,100+rec,250);
  TextOut(65+rec,207,inttostr (arr_key[i]));
  rectangle(50+rec,250,100+rec,300);
  TextOut(65+rec,257,s1[i]);
  rectangle(50+rec,300,100+rec,350);
  TextOut(65+rec,307,inttostr (arr_mass[i]-2));
  rectangle(50+rec,350,100+rec,400);
  TextOut(65+rec,357,key_out[i]);
  rectangle(50+rec,400,100+rec,450);
  TextOut(65+rec,407,inttostr (arr_key[i]));
  rectangle(50+rec,450,100+rec,500);
  TextOut(65+rec,457,s2[i]);
  rectangle(50+rec,500,100+rec,550);
  TextOut(65+rec,507,inttostr (arr_demass[i]-2));
  end;
  readln;
  clrscr;
  readln;
  SetFontSize(10);
  assign(t,'output.txt');
  reset(t);
  rewrite(t);

      for i:=0 to round(length(alphabet2)) do begin//1
      for j:=1 to round(length(alphabet2)) do begin
      rec:=j+k;
      tablchar[j]:=alphabet[rec];
     // tabldigit[j]:=rec;
      write(tablchar[j],'');
      //write(tabldigit[j],'');
       write(t,tablchar[j],'');
      end;

      write(t,'');
      k:=k+1;
      writeln;
       end;//1
      for i:=0 to round(length(alphabet2)) do begin//1
      for j:=1 to round(length(alphabet2)) do begin
      rec:=j+k;
      tablchar[j]:=alphabet[rec];
     // tabldigit[j]:=rec;
    //  write(t,tablchar[j],'');
      //write(tabldigit[j],'');
      end;
     // write(t, tablchar[j],'');
      k:=k+1;

       end;
       close(t);

   end.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question