Code:
string encryptKey(string key)
{
string password;
int passwordlength;
int keylength = key.length();
string encryptedKey;
cin >> password; //executed
passwordlength = password.length();
cin >> password; //executed
for(int x = 0;x<keylength;x++)
{
for(int o = 0;o<passwordlength;o++)
{
encryptedKey[x]=key[x]^password[o];
cout << encryptedKey[x];
cin >> password;
}
cout << encryptedKey[x];
cin >> password;
}
cout << key;
cout << passwordlength; //executed
cout << encryptedKey;
cin >> password; //executed
return encryptedKey;
}
so this function is supposed to take a key passed to it as a parameter, ask for a password, encrypt the key with the password using that XOR thing and then return the encrypted key. I put in a bunch of extra couts and cins to try to figure out what the program is doing, because its not doing what its supposed to. When I run the program it asks for input twice, outputs the passwordlength, asks for input again and then finishes. the string that it returns doesnt contain anything inside of it either
the output looks kinda like this:
Code:
asdf (asks for input)
sd (asks for input again)
4 (displays the length of password)
df (asks for input)
so why doesnt it go through the for loops and actually encrypt the password