There are many algorithms that can be used to encrypt a message. One of these algorithms can be described as follows: • Choose a “code word”. For example, “fortran”. • Assign integer values to each of the characters in the code word corresponding to their placement in the alphabet. In the case of the code word “fortran”, the integer values would be (6, 15, 18, 20, 18, 1, 14). • Change each character in the message to be encrypted by adding the code word values determined above (in order) to each of the characters in the message to be encrypted. The code word is reused as many times as necessary. For example, suppose that we want to encrypt the message “hello”, we would first determine the integer values for each character in the message (8, 5, 12, 12, 15). Each of these values would be modified by adding the code word values, ie. (8+6, 5+15, 12+18, 12+20, 15+18) = (14, 20, 30, 32, 33). The resulting values are then translated back to character values, using circular addition (ie. 33 would refer to the 7th letter of the alphabet). So the message “hello” would be encrypted as “ntdfg”. • If there are spaces in the input message, they are assigned a value of 0. For example, using the “fortran” code word, “hello there” would be encrypted using (8+6, 5+15, 12+18, 12+20, 15+18, 0+1, 20+14, 8+6, 5+15, 18+18, 5+20) = (14, 20, 4, 6, 7, 1, 8, 14, 20, 10, 25), corresponding to “ntdfgahntjy”. • The encrypted form of the message is usually broken up into equal length “words”. For example, using a word length of 6, the above encrypted message would be “ntdfga hntjy”. Write a Fortran program to read in a code word, the encrypted word length, and a message to be encrypted, and output the encrypted form. Note that your code can be limited to only lowercase messages. Your program should make use of allocatable arrays. 2. When you have your encryption code working, move it into a function that is contained within a module. The module should contain variables for the code word and the “word” length. Use your main program to test your module. 3. Add a function to your module to decrypt a message that has been encrypted as above. Test your decryption function within your main program. The following may be useful for this question: • A section of a string can be extracted by specifying start and end indices. For example, if word is a string variable, then word(1:3) is the first 3 characters of word. • LEN_TRIM(string) - Returns the length of a character string, ignoring any trailing blanks. • IACHAR(C) - returns the code for the ASCII character in the first character position of C. • ACHAR(I) - returns the character located at position I in the ASCII sequence.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The language used for the code is fortran 2008. Thank you

1. There are many algorithms that can be used to encrypt a message. One of these algorithms can be described as follows:

• Choose a “code word”. For example, “fortran”. • Assign integer values to each of the characters in the code word corresponding to their placement in the alphabet. In the case of the code word “fortran”, the integer values would be (6, 15, 18, 20, 18, 1, 14).

• Change each character in the message to be encrypted by adding the code word values determined above (in order) to each of the characters in the message to be encrypted. The code word is reused as many times as necessary. For example, suppose that we want to encrypt the message “hello”, we would first determine the integer values for each character in the message (8, 5, 12, 12, 15). Each of these values would be modified by adding the code word values, ie. (8+6, 5+15, 12+18, 12+20, 15+18) = (14, 20, 30, 32, 33). The resulting values are then translated back to character values, using circular addition (ie. 33 would refer to the 7th letter of the alphabet). So the message “hello” would be encrypted as “ntdfg”.

• If there are spaces in the input message, they are assigned a value of 0. For example, using the “fortran” code word, “hello there” would be encrypted using (8+6, 5+15, 12+18, 12+20, 15+18, 0+1, 20+14, 8+6, 5+15, 18+18, 5+20) = (14, 20, 4, 6, 7, 1, 8, 14, 20, 10, 25), corresponding to “ntdfgahntjy”.

• The encrypted form of the message is usually broken up into equal length “words”. For example, using a word length of 6, the above encrypted message would be “ntdfga hntjy”. Write a Fortran program to read in a code word, the encrypted word length, and a message to be encrypted, and output the encrypted form. Note that your code can be limited to only lowercase messages. Your program should make use of allocatable arrays.

2. When you have your encryption code working, move it into a function that is contained within a module. The module should contain variables for the code word and the “word” length. Use your main program to test your module.

3. Add a function to your module to decrypt a message that has been encrypted as above. Test your decryption function within your main program.

The following may be useful for this question:

• A section of a string can be extracted by specifying start and end indices. For example, if word is a string variable, then word(1:3) is the first 3 characters of word.

• LEN_TRIM(string) - Returns the length of a character string, ignoring any trailing blanks.

• IACHAR(C) - returns the code for the ASCII character in the first character position of C.

• ACHAR(I) - returns the character located at position I in the ASCII sequence.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Public key encryption
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education