John
Member
- Joined
- Aug 8, 2009
- Messages
- 121
- Reaction score
- 0
- Points
- 16
//I'm trying to make a simple encryption program, which first
//asks the user for all the letters of the alphabet and the user // can input them in random order.
//i.e
string encryptkey;
cin >> encryptkey;
// i.e
//qazxcsdwerfvbgtyhnmjuiklo
//q= 0, a = 1, z = 3... etc
//the program will then ask the user for a word that will be //encrypted. i.e
string encryptword;
cin >> encryptword;
// user inputs a word
//i.e dafdhg
//the program will encrypt the word so that it will check where //each of the characters are in the vector and will then make a //new vector which is the encrypted word. The encryption works //so that it replaces the characters according to the alphabet.
//i.e
//qqqaz is encrypted into aaabc
//because q is the first char so it switches to a. a is the second //so it switches to b etc..
for ( i = 0; i < encryptword.length(); ++i )
// THIS IS WHERE I NEED HELP
// the program will check the first char of the encryptword and //find the character in the encryptkey.
// How can I do this?
//i.e if the word is
//daafg;
// the program will search the encryptionkey and find out, where //the first character is.
int firstchar=static_cast <int> (encryptkey.find("d"));
// in this case firstchar = 7 and the 7th letter of the alphabet is
// g
// the program will then insert this character to a vector
encrypted.push_back('g')
}
//asks the user for all the letters of the alphabet and the user // can input them in random order.
//i.e
string encryptkey;
cin >> encryptkey;
// i.e
//qazxcsdwerfvbgtyhnmjuiklo
//q= 0, a = 1, z = 3... etc
//the program will then ask the user for a word that will be //encrypted. i.e
string encryptword;
cin >> encryptword;
// user inputs a word
//i.e dafdhg
//the program will encrypt the word so that it will check where //each of the characters are in the vector and will then make a //new vector which is the encrypted word. The encryption works //so that it replaces the characters according to the alphabet.
//i.e
//qqqaz is encrypted into aaabc
//because q is the first char so it switches to a. a is the second //so it switches to b etc..
for ( i = 0; i < encryptword.length(); ++i )
// THIS IS WHERE I NEED HELP
// the program will check the first char of the encryptword and //find the character in the encryptkey.
// How can I do this?
//i.e if the word is
//daafg;
// the program will search the encryptionkey and find out, where //the first character is.
int firstchar=static_cast <int> (encryptkey.find("d"));
// in this case firstchar = 7 and the 7th letter of the alphabet is
// g
// the program will then insert this character to a vector
encrypted.push_back('g')
}