Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed Java programming !
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 original string, int prime) This function looks at every character of the string it receives (which contains the secret message), and add to the characters integer value the calculated prime number. 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 decrypt Message 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_2

Step: 3

blur-text-image_3

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago