My vigenere program works for everything except for when I have both capital and lowercase letters in the keyword. It works when I have only one type, so I don't think it is a problem with the formula, maybe a problem with the way I embedded loops. Does anyone have any idea of why this is happening? has it happened to anyone else? I would rather not post my code just because it seems to be so close to the correct solution, but if it is needed I could post it and then delete it after the question is answered.

  • It's hard to troubleshoot without seeing at least some code. If you have time to discuss the problem in chat, or can give us a short excerpt of your code that shows where the problem occurs, we may be able to help. An alternative would be to ask for volunteers on Facebook or reddit to discuss your code privately.
    – Air
    Jul 2 '14 at 18:09

I imagine the problem is with the way you're assigning the characters of the keyword a value in [0, 25]. For example, if my keyword is "BAZ", the keys should be {1, 0, 25} respectively. Similarly, if the key is "baz" or "BaZ".

To solve this problem, you'll need to sort of standardize things when working with the characters of the keyword.

For example, to get the key value of a the current character in the keyword, I chose to convert the current character to a lowercase character and subtract 'a' from it!

tolower(keyword[index % kl]) - 'a'
  • I got it. I was using the same variable for all the ciphering equations. after changing each to a different variable, the program works fine.
    – Sofia
    Jul 2 '14 at 20:40
  • I'm sorry! I didn't get that! Was this the answer?
    – kzidane
    Jul 2 '14 at 20:44
  • Yeah. I would post it in "answer your own question" but I don't have enough reputation. honestly I just tried a bunch of random changes. this one worked.
    – Sofia
    Jul 2 '14 at 20:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .