encrypting and decrypting using the alphabet;
Assignment Specifications
Decryption and encryption is a very useful activity to hide messages or data. Encryption is utilized to store passwords, store user information and in many other means when the sender does not want the message to be easily readable to anyone other than the intended reader.
Your Assignment
You must write a program that can both decrypt and encrypt a single word that is entered by the user. The initial choice of encryption and decryption is left up to the user. Additionally, the user will enter a value to be utilized when determining how to translate the character.
Alphabetic Positions
Positions start at zero. If the letter is ‘a’ then its position in the alphabet is 0 and if the letter is ‘c’ the position is 2 and so on through ‘z’.
Algorithm
Acquire the method to perform (encryption or decryption).
Check whether the method specified is valid.
Acquire the translation map
If keyword default is entered, utilize the default map.
default map: “zyxwvutsrqponmlkjihgfedcba”
Validate the size of the map (26 characters)
Acquire the word to encrypt or decrypt, validate depending on method
Validate whether the word can be encrypted
All characters in word must be lowercase letters
Validate whether the word can be decrypted
All characters in word exist in map
Perform encryption or decryption
Encryption: Convert all characters in word to a character in the map
Given a character in the word, calculate its position in the alphabet
Replace the character in the word with the character in map at that position.
Decryption: Convert all characters in the word by utilizing the discovered map index
Given a character in the word, determine its index in the map string
This is the position of the character in the alphabet!
Add the position to the first character in range of valid characters for a word
What is the range of valid characters? Check the validation step. What is the first character in that range?
Hints/Tips
Implement the algorithm in the order that is specified.
If you get to an error point, immediately exit the program (within main just return 0;)
Use only a single map variable, assigning a proper value into it based on user input.