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 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.

Recommended Answers

All 10 Replies

That question looks like an assignment so go ahead and put your question in another reply.

My question is: "What is this addictive operation?"

yeah its an assignment, look here what i did

I looked at what you did, but where is the question and where is the answer to my question?

First, write out the solution (as you understand it) in pseudo-code. IE, plain language describing the problem and solution. Then, we may be able to help you put it into code. Do bear in mind that Pascal is an ANTIQUE language (Niklas Worth wrote it in the 1960's or 70's as a teaching language). He went on to write Modula, a much more complete programming language. FWI, my good friend Bruce Ravenel was a graduate student of Worth back when before Bruce went to work for Intel and became one of the 2 principal designers of the 8086/8087 processor families...

I can send you a copy of Bruce's IEEE article (published in 1970) "Toward a Pascal Standard", but it is over 4MB so I will need a real email address for you, which you can send me via Daniweb in-mail.

rProffitt= My question is how do i intepret it on Lazarus source editor, i have created the form. For the addictive operation, is what i also dont understand.

I think it was meant to be "additive" not "addictive" operation.

David,

I admit that I have been caught behind the more advanced ideas. I think you may mean addition but maybe your class has some operation that I wasn't taught.

That said I compiled your code as-is and it did run. I used http://www.onlinecompiler.net/pascal

Also, that should have been Niklas Wirth, not Worth... Doh! And to think, I have a couple of his books on my shelf! Stupid keyboard!

Hi,
Its 'Additive' not 'Addictive'.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.