Why doesn't this display the string?
string decrypt(const string& ciphertext,cons t string& key)
{
string decrypted;
decrypted.resiz e(ciphertext.si ze()); // allocates the string for the
correct size.
string::iterato r itEnc=decrypted .begin(),itEnd= decrypted.end() ;
string::const_i terator itSource=cipher text.begin();
string::const_i terator itKey=key.begin (),itKeyEnd=key .end();
for(;itEnc!=itE nd;++itEnc,++it Source,++itKey)
{
if (itKey==itKeyEn d) itKey=key.begin ();
string c((*itSource)-((*itKey)-'A'));
if (c[itEnc]<'A') c[itEnc]+=26;
else
*itEnc=c;
}
return decrypted;
}
Any suggestions? Thanks
string decrypt(const string& ciphertext,cons t string& key)
{
string decrypted;
decrypted.resiz e(ciphertext.si ze()); // allocates the string for the
correct size.
string::iterato r itEnc=decrypted .begin(),itEnd= decrypted.end() ;
string::const_i terator itSource=cipher text.begin();
string::const_i terator itKey=key.begin (),itKeyEnd=key .end();
for(;itEnc!=itE nd;++itEnc,++it Source,++itKey)
{
if (itKey==itKeyEn d) itKey=key.begin ();
string c((*itSource)-((*itKey)-'A'));
if (c[itEnc]<'A') c[itEnc]+=26;
else
*itEnc=c;
}
return decrypted;
}
Any suggestions? Thanks
Comment