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