Implement Shift cipher using Python or Java. The user should be prompted to provide a number between 0-25 and pick encryption (e) or decryption (d) and a phrase. Your program will either encrypt or decrypt the phrase and show the result on the console.

Respuesta :

Answer:

See below

Explanation:

This question is usually in response to having just learned arrays and string/character processing.  Also, encrypted text is all caps, decrypted text is all lowercase.  Convert the string accordingly with the uppercase/lowercase functions for your particular language.

Then, follow the following algorithm:

Loop through each character of the string.  Add (or subtract if decrypting) the character.  If it goes beyond the last letter of the alphabet, then subtract the shift from 26 (which is the number of letters in the alphabet.  Add the character to a new string, and return it.