Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Caesar Cipher The Caesar ciphere is an ancient method of encrypting text, i.e. to transform text into a format that is unreadable for anyone
The Caesar Cipher The Caesar ciphere is an ancient method of encrypting text, i.e. to transform text into a format that is unreadable for anyone without a secret key. It is believed that Julius Caesar actually used such a cipher for his correspondence. Unfortunately for him this type of cipher is easily broken using a frequency analysis method which is outlined below. Your assignment is to implement this in Java. Part 1: Encrypting and Decrypting The Caesar cipher is a "rotation cipher" and operates by translating each letter into the one that is shifted along the alphabet by a fixed distance. This distance is called the shift. It is the same for all letters in the alphabet and therefore can be seen as the secret key to encrypt and decrypt: To encrypt your text using a given shift, you translate letters by that many places later in the alphabet. A Caesar cipher with shift 3 can be illustrated as follows. For example, if your text to encrypt is "Meet me at midnight under the bridge" and your shift is 3 , the encrypted text is "Phhw ph dw plsqlikw xaghu whh eulgin" becase the letter ' M ' gets translated into a ' P ' and ' e ' gets translated into ' h ' and so on. We "wrap around' at the end of the alphabet so that ' z ' gets changed to a 'c' given a shift of 3 . We can interpret a negative value for the shift as translating letters backwards (e. ga an 'f' gets encrypted as the letter ' b ' if the shitt is 4. Requirements In a file called implement the following ! methods. a method called implement the following methods. rotate, and return the character rotated by the given shift; as a Lower-case characters should be translated into lower-case characters, capitalised ones into capitalised ones; and all other characters should remain untouched. another method called that rotates a whole string. It should again take two arguments: the first is an integer [int ] shift and the second a to rotate. It should return the string rotated by the given shift, as a Of course you may use your character rotation method here. method, that allows to encode/decode text. This should read both the shift as well as the plain text from command line arguments. The first argument is interpreted as the shift and the second one as a fstring) message to be rotated. Your method should check if it was called with exactly two arguments and complain othenvise. The only output printed by the program should be the rotated string output. See below for example outputs. Your program needs to print the exact same output to be considered correct. 5. Java Coesar 3" The ships hurg in the sky in mach the sime may that bricks don't:" 5. java Coeser -13. "The ships hung in the sky in wuch the sane nay thet beicks don"t." fur funcf what wo gur fat va ehpu gur finer inl gang oevpxe pho'g. 5. jeva Caesar 13 the ships hung in the sky in auch the same way that bricks dontt. Too nony poraneters! Hisege: jowa caosor n "cipher text" 5. java Coesor 13 Too fon paramerst Usaget javo Caesar-n "cipher text
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started