Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Imagine you are an agent and for some secret government agency. You work together with a colleague who is a double agent and has

image text in transcribedJava
Imagine you are an agent and for some secret government agency. You work together with a colleague who is a double agent and has infiltrated some underground organization. You need to get a message to him, but you cannot send him a clear text message, since someone might intercept your message and uncover his true identity. You have to encrypt the message, and send it to him. For this purpose, you're going to do the following: First you will read the encryption prime number limit and the secret message from the text file that is given to you by the Agency. The text file is called: SecretMessage.txt The first line contains an integer (the prime number limit). The second line contains the secret message you have to encrypt Then, you will write a function called getEncryptionPrime. This function takes an integer as parameter, and returns to you the highest prime number between zero and the prime number limit (for example, if the prime number limit is 100, this function will return 97. Now you will encrypt the message. For this purpose, write a function called: encrypt(String originalString, int prime) This function looks at every character of the string it receives (which contains the secret message), and add to the character's integer value the calculated prime number (type cast the character to an integer). Put the resulting characters together in a new String to assemble the encrypted message, and output the encrypted message to the console like: The encrypted message is: " Let the function return the encrypted String. Finally, write a function called decryptMessage that takes a String and an integer as function parameters. This function is responsible to decrypt the message back to its readable content. Call this function from your main function, give it the encrypted message and the prime number to reverse the encryption, and output the original message from this function to the console like: "The decrypted message is: " Example output (not the actual message): The encrypted message is: The decrypted message is: The meeting takes place at midnight

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

If ( A^2 - A + I = 0 ), then inverse of matrix ( A ) is?

Answered: 1 week ago

Question

What is computer neworking ?

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago