Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 Caesar Cipher (30 points) The Caesar cipher is a (very insecure) method for encrypting text dating back to the Romans. It is the same
1 Caesar Cipher (30 points) The Caesar cipher is a (very insecure) method for encrypting text dating back to the Romans. It is the same alphabetic shift cipher as is used in the Secret Decoder Rings that no longer come as prizes in breakfast cereals and Cracker Jacks. Each letter in a text is replaced by the letter that occurs some fixed number of positions later in the alphabet. For instance, if the cipher implemented a shift of 3 positions, 'A' would be transformed to 'D', 'B' to 'E', 'L' to 'O' and so forth. Letters at the end of the alphabet wrap around to the beginning, so 'Z' would get coded as 'C'. To decode the message, simply reverse the shift Java characters are represented in Unicode, which is a complex character representation that is supposed to allow writing in the alphabet of every human language, including Cyrillic, Tagalog, Hmong, Egyptian hieroglyphics, Chinese and (ahem) Klingon. However, the first 128 characters in Unicode are the same as the English-only ASCII representation that has been around since the 1950s. In ASCII, printable English characters start at 32 (space) and end at 126 (tilde), with all of the alphabetic characters in between. The letter 'A' is 65, 'B' is 66, 'a' is 97, etc. We can generalize the Caesar cipher to handle all of these characters, using an arbitrary shift size as our key. The algorithm is, then if charValue 126 outputChar - (char) charValue // leave alone charvalue charvalue + key // We include both of these so that we can encode by using a positive numbeir // and decode using the same number as a negative if charvalue > 126 charvalue = charvalue - 95 // ( 127-32) if charvalue
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