0

My vigenere code enciphers properly, but if a non-alpha (i.e. space or number) character is entered in the code to be ciphered, it loops through an extra time. It doesn't matter whether it is one non-alpha or ten non-alpha, one extra loop.

For example, when I enter the example here is my results:

jharvard@appliance (~/Dropbox/pset2): ./vigenere bacon  
Enter text to be ciphered:              
Meet me at the park at eleven am               
Negh zf av huf pcfx bt gzrwep oz              
Negh zf av huf pcfx bt gzrwep oz

It isn't an extra print command because if I enter 'bacons' for the code word, I get:

jharvard@appliance (~/Dropbox/pset2): ./vigenere bacons      
Enter text to be ciphered:                      
Meet me at the park at eleven am   
Negh zw bt vvr hbrm og wmexsa sn         
Mgsg ef av huw qaty nl flgjrf bm

Any thoughts on where to focus?

2 Answers 2

1

If you've used a function, then you might have accidentally called the function twice.

0

You'll want the code to stop once it reaches the last character of the cipher word(s). Check to see where your loop is stopping.

You must log in to answer this question.

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