0

I am unable to make my key wrap around. The first three letters are working, however, after those, the program stops working and outputs garbage (or really secure cipher :))

Code (Removed)

CS50Check

2
  • Are you sure the code you posted was for vigenere? As a caesar cypher, the program seems fine (at least on the couple tests I did). Your problem is that your program doesn't handle key words, only single numbers, which is why the check program worked on "a." Maybe I'm missing something though.
    – cb3k
    Aug 13 '16 at 19:08
  • Yeah I posted the wrong code on accident, I put in the new code now.
    – Human
    Aug 13 '16 at 21:58
1

After the first pass through the key, every char in the key has been converted to numbers between 0 and 25 inclusive. Starting on the second pass through, the else clauses are executing, moving the key values into negative numbers. The results now become garbage.

The concept of converting the key to numbers from 0 to 25 is good. You just need to do it only once. Maybe you might consider a for loop to convert the key array once before starting the for loop to process the plain text?

Also, you have another error waiting in the wings. What about upper vs. lower case in the plain text?

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

This site is temporarily in read only mode and not accepting new answers.

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