
Voici une proposition:
\begin{python}
from string import ascii_uppercase

def chiffrement_vigenere(message,key):
    message = message.upper()
    key = key.upper()
    chiffrement = ''
    if len(key) > len(message):
        key = key[:len(message)]
    elif len(key) < len(message):
        while len(key) < len(message):
            key += key
        key = key[:len(message)]
    for p in range( len(message) ):
        x = ascii_uppercase.index(message[p])
        y = ascii_uppercase.index(key[p])
        r = (x+y)%26
        chiffrement += ascii_uppercase[r]
    return chiffrement
\end{python}
