I've worked on (and dreamed about) Vigenere for a few days now, and I'm almost there. I think! If I try out my code separately for lower and uppercase letters (by commenting out the irrelevant part), it works fine. But together, I get the wrong kind of gibberish.
Check50 throws these errors:
:( encrypts "a" as "a" using "a" as keyword
\ expected output, but not "T:\n"
:( encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword
\ expected output, but not "Q7H.JJ`,W=, KKU;R8 Z@Y?_+^DI/!\n"
:( encrypts "BaRFoo" as "CaQGon" using "BaZ" as keyword
\ expected output, but not "CT:QGH.nT\n"
:) encrypts "BARFOO" as "CAQGON" using "BAZ" as keyword
Note that uppercase seems to work, but not lowercase. (If I comment out uppercase, lowercase works.)
Here's the essentials of my code, in pseudocode:
- loop over string key
-- is not alpha? return 1.
-- is alpha?
--- is lower? convert key to numbers so that a == 0
--- is upper? convert key to numbers so that A == 0
- loop over string plaintext
-- is alpha?
--- is lower? encrypt, increase key counter
--- is upper? encrypt, increase key counter
-- print %c
-- is not alpha? don't encrypt, print %c, don't increase key counter
I'd be grateful for any ideas.