Found the program code, you need to compile and run. I do it in RAD Studio 10.2 I create a new unit, insert the code. It produces errors by buttons, forms, etc.
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Memo1: TMemo; Memo2: TMemo; Memo3: TMemo; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; // Alfabet:array [0..255] of char; str:string; newstr:string ; a,c,t,m:integer; implementation {$R *.DFM} function testingcount(s:string):boolean; var SetCount: set of char; i:integer; begin TRIM(S); IF s=” then begin testingcount:=false; exit; end; SetCount := ['1', '2','3′,'4′,'5′,'6′,'7′,'8′,'9′,'0′]; testingcount:=true; if length(s)>1 then if (not(s[1] in SetCount) and (not(s[1]<>'0′))) then // проверка, чтобы число не начиналось с нуля begin testingcount:=false; exit; end; for i:=2 to length(s) do if (not(s[i] in SetCount)) then begin testingcount:=false; exit; end; end; function code(s:char):char; //кодирование и декодирование var j,litera:integer; begin t:=(a*t+c)mod m; litera:=t xor ord(s); code:=chr(litera); end; procedure read; var i:integer; begin if testingcount(Form1.Edit1.Text) then a:=StrToInt(Form1.Edit1.Text) else begin ShowMessage('Некорректно задан параметр А'); exit; end; if testingcount(Form1.Edit2.Text) then c:=StrToInt(Form1.Edit2.Text) else begin ShowMessage('Некорректно задан параметр C'); exit; end; if testingcount(Form1.Edit3.Text) then t:=StrToInt(Form1.Edit3.Text) else begin ShowMessage('Некорректно задана порождающая величина'); exit; end; end; procedure transformation(var s,s1:string); var i:integer; res:char; begin s1:=”; m:=32; for i:=1 to length(s) do begin if ((ord(s[i])=$A) or (ord(s[i])=$D) ) then s1:=s1+s[i] else begin res:=code(s[i]); s1:=s1+res; end; end; end; procedure TForm1.Button1Click(Sender: TObject); var j,litera:integer; begin read; str:=Form1.Memo1.Text; transformation(str,newstr); Form1.Memo2.Text:=NEWstr; end; procedure TForm1.Button2Click(Sender: TObject); begin Form1.Memo1.Clear; end; procedure TForm1.Button4Click(Sender: TObject); begin Form1.Memo2.Clear; end; procedure TForm1.Button3Click(Sender: TObject); begin Form1.Memo3.Text:=”; newstr:=Form1.Memo2.Text; read; transformation(newstr,str); Form1.Memo3.Text:=str; end; end.
{$R *.DFM}line{$R *.DFM}tell you anything? - Igor