I have a homework assignment where I have to make a function that is used to reverse the effects of a caesar shift on a string. For example, if the string after the shift is "fghij", and the shift value is 5, the function should yield "abcde." This works when I try it on visualstudiocode. When I submit the assignment, it seems as if my function did nothing. The function is as follows:
string decryptCaesar(string ciphertext, int rshift)
{
string plaintext;
int cipher_length = ciphertext.length();
for(int a = 0; a < cipher_length; a++)
{
char individual = char(ciphertext[a]);
if(isalpha(individual) == true)
{
if(65 <= int(individual) && int(individual) <= 90)
{
individual = char(((int(individual) - 65 + 26 - rshift) % 26) + 65);
}
else
{
individual = char(((int(individual) - 97 + 26 - rshift) % 26) + 97);
}
}
plaintext += individual;
}
return plaintext;
}