assignment

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.

how do i create a map??

#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
int input1, input2;

char letters [27] = 'abcdefghijklmnopqrstuvwxyz';

cout<< "What is the method ( encryption or decryption )? \n";
cin>> input1;

cout<< "What is the translation map (type 'default' to use default): \n";
cin>> input2;

if ( ( input1 == "encryption" ) && ( input2 == "default" ) ){


}
if ( ( input1 == "decryption" ) && ( input2 == "default" ) ) {


}






return 0;
}

im stuck guys. im taking a six week course on intro to cs. and ive never dealt with this lol
Your default map is

char defmap[27] = “zyxwvutsrqponmlkjihgfedcba”;

Note, for example, that the position of 'c' matches the position of 'x' in the default map.

A different map would be the same thing, but more severely mixed up than merely a reverse alphabet
Last edited on
ahhh I see kind sir! my professor gave us this assignment. but we haven't gone over any of this. so im looking for all the help I can get.
so apparently my map has to start with a = 0 and b = 1. the char letters [] <- input must be 26?
Topic archived. No new replies allowed.