so far the vigenere.c works if the keyword and the plaintext are the same size of characters, but once it tries to wrap around if the keyword is smaller than the plaintext the output goes wrong. Here is the code so far: https://gist.github.com/ohmichel/15232f42a571dc1f5e74196a6be15901

Any tip, hint or suggestion will be appreciated. XOXO


I think

k[j] = k[j] - 'a';

is the culprit. What happens if you visit this place again with same j? You'd subtract 'a' again. Either do it once, or don't store the value.

  • so you suggest to not use it? Trying to use it but only once. The thing is that it helps but it doesn't wrap around. Works if the keyword and plaintext are the same size. – Michel Ortega Sep 25 '17 at 17:23
  • You could use k[j] - 'a' later, in the formula, or do this once, for example before your main loop. I somewhat dislike the idea of storing numbers in a char[], though, at least if it were meant to represent a string. – Blauelf Sep 26 '17 at 7:17

You must log in to answer this question.

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