Question: Create a message encryption system application that translates every message character to

Question: Create a message encryption system application that translates every message character to its ASCII equivalent and pads the resultant code with a chosen random key based on an addictive operation.
Answer:

program Encrypt;
type tab=array[1..255] of byte;
function Sum(T:tab):integer;
var i,s:integer;
begin
S:=0;
for i:=1 to length(T) do
s:=s+T[i];
sum:=s;
end;
var
s: string;
ascii: array [1..255] of byte;
i,code: integer;
begin;
write('Enter a string: '); readln(s);
for i:=1 to length(s) do
ascii[i]:=ord(s[i]);
{ s[i] accesses each element of the string as a char.
ord returns the ASCII value of the char. }
writeln('ASCII vals: ');
for i:=1 to length(s) do
write('|',ascii[i],'|');
{ Generate a random key }
code:=Random(1000);
writeln;
writeln('the random key is : ',code);
writeln('the encrypted message is :',sum(ascii)*code);
end.

After showing this to him, he said i should use Lazarus to create the application with GUI and use A menu that can allow me choose to input a string and then encrypt it. I have tried it on Lazarus but failed and i dint understand the menu. please i need help, Its a assignment.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories