This is my code for the cipher itself. No mater what key I use it shifts all the letters by only 1, always.
Please HELP!
for (i = 0; i < m; i++) //Loop through user's input's length.
{
for (j = 0; j < 26; j++)
{
key[j] = j; //Assign numbers 0 to 25 to each letter of the key.
}
if (isalpha(userMessage[i])) //If string index has letter...
{
if (islower(userMessage[i])) //...and if letter is lowercase...
{
/*...shift characters by key amount inside lowercase ASCII table...*/
userMessage[i] = (((userMessage[i] - 97) + key[j % n]) % 26) + 97;
}
else if (isupper(userMessage[i])) //...or if letter is uppercase...
{
/*...shift characters by key amount inside uppercase ASCII table */
userMessage[i] = (((userMessage[i] - 65) + key[j % n]) % 26) + 65;
}
}
else if (isdigit(userMessage[i]) || isspace(userMessage[i])) //And if string index has non-alphabetical value...
{
userMessage[i] = userMessage[i]; //...keep value unchanged.
}
printf("%c", userMessage[i]); //Print ciphered text.
}