Java Application – CaesarCipher

Evaluation of the key Cross Cultural: Management Influences at Barclays PLC
June 18, 2020
The American West Frontier
June 18, 2020

Java Application – CaesarCipher

Java Application – CaesarCipher

In cryptography, a cipher (or cypher) is an algorithm for performing encryption or decryption.  There are many algorithms that have been invented.

A Caesar Cipher is a very simple technique.  The algorithm is named after Julius Caesar who used it in some of his correspondence.

The algorithm transforms normal text by shifting each letter a certain number of characters either to the left or the right.  The shift direction and count is known as the key.

Example 1:  Key is -3 (shift left 3)

Example 2:  Key is +3 (shift right 3)

Here is a URL for a site that allows you to test the algorithm
http://www.xarg.org/tools/caesar-cipher/

Notice that the case of the original text is maintained and that non-letters are not encrypted.
Create a java application to prompt the user for a key and a phrase.  After the information is entered, encrypt the phrase using the provided key.

Validate the key.  The absolute value of the key cannot be less than 1 or greater than 25.  Prompt the user in a loop until a valid key is entered.

Put the code in a loop to continue prompting for more keys and phrases to encrypt.

Here is an example of how the program might appear

Name the Java Class:  CaesarCipher

Grading Rubric

•    Correct File Name (CaesarCipher.java) – case sensitive
•    Correct Class Name (CaesarCipher) – case sensitive
•    Correct Style – comments
•    Correct Style – indentation
•    Correct Style – White Space
•    Free of syntax errors
•    Scanner object to read from keyboard
•    Program loop to continue
•    Prompt for and validate the key
•    Validate the key in a loop
•    Prompt for and read a phrase
•    Correctly encrypt the phrase
•    Display the encrypted phrase