Decrypting a secret message

My assignment is: In this assignment, you’ll decrypt a secret message using a cipher. A “cipher” is a program that
converts a message in normal text into a secret message, and vice­versa. For example, the
normal message “meet at five pm” might be converted to the secret message “[@@, !, (#<@ ][“
using a cipher. The secret message can be sent to a friend. Nobody else could read the
message, expect the friend whose cipher would convert the secret message back to normal
text.
The starter program decrypts the first character in a secret message if that first character is ‘{‘.

This is my code but everytime I compile it I enter a decrypted message and it spits back what I've entered.


#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
vector<char> normalV(26);
vector<char> cipherV(26);
string toDec = "";
string beenDec = "";

normalV.at(0) = 'a'; cipherV.at(0) = '!';
normalV.at(0) = 'b'; cipherV.at(0) = '^';
normalV.at(0) = 'c'; cipherV.at(0) = '&';
normalV.at(0) = 'd'; cipherV.at(0) = '*';
normalV.at(0) = 'e'; cipherV.at(0) = '@';
normalV.at(0) = 'f'; cipherV.at(0) = '(';
normalV.at(0) = 'g'; cipherV.at(0) = ')';
normalV.at(0) = 'h'; cipherV.at(0) = '-';
normalV.at(0) = 'i'; cipherV.at(0) = '#';
normalV.at(0) = 'j'; cipherV.at(0) = '_';
normalV.at(0) = 'k'; cipherV.at(0) = '=';
normalV.at(0) = 'l'; cipherV.at(0) = '+';
normalV.at(0) = 'm'; cipherV.at(0) = '[';
normalV.at(0) = 'n'; cipherV.at(0) = '{';
normalV.at(0) = 'o'; cipherV.at(0) = '$';
normalV.at(0) = 'p'; cipherV.at(0) = ']';
normalV.at(0) = 'q'; cipherV.at(0) = '}';
normalV.at(0) = 'r'; cipherV.at(0) = ';';
normalV.at(0) = 's'; cipherV.at(0) = ':';
normalV.at(0) = 't'; cipherV.at(0) = ',';
normalV.at(0) = 'u'; cipherV.at(0) = '%';
normalV.at(0) = 'v'; cipherV.at(0) = '<';
normalV.at(0) = 'w'; cipherV.at(0) = '.';
normalV.at(0) = 'x'; cipherV.at(0) = '>';
normalV.at(0) = 'y'; cipherV.at(0) = '/';
normalV.at(0) = 'z'; cipherV.at(0) = '?';

// Get secret message
do {
cout << "Enter a secret message: ";
getline(cin, toDec);
} while (toDec.length() == 0);

beenDec = toDec;

// Decrypt secret message
if (toDec.at(0) == cipherV.at(0)) {
beenDec.at(0) = normalV.at(0);
}

cout << "Decrypted message: " << beenDec << endl;

return 0;
}
if (toDec.at(0) == cipherV.at(0)) when is this true?

Topic archived. No new replies allowed.