I am having trouble with the cipher formula. I am working on just getting lowercase character right using the keyword "bacon" and plain text string "test". I get a result of "nxna". Any help is appreciated. Here is the relevant code.
for (int i = 0, pl = strlen(plaintext), kl = strlen(keyword), index = 0; i < pl; i++)
{
char current = plaintext[i];
if (isalpha (current))
{
if (islower(current))
current = (current - 'a' + keyword[index % kl]) % 26 + 'a';
printf("%c" , current);
index++;
}
k1
should not be defined and updated in the loop declaration. Instead it should have its own line in the for loop.