Vigenere

Lesson 39: Vigenere Cipher

Here is the follow up video about Vigenere.

Here is a great way to iterate over the password using a generator function:

def foo(p):
    x=0
    while True:
        #yield p[x]
        yield p[x%len(p)]
        x+=1
        #if x==len(p):
        #    x=0

letter=foo('password')
next(letter)
next(letter)
next(letter)
next(letter)

Now we can just call next(letter) as we iterate through the text to encrypt or decrypt.