def decipher_vigenere(msg, key, symbols=None):
 (msg, key, A) = _prep(msg, key, symbols)
 map = {c: i for (i, c) in enumerate(A)}
 N = len(A)
 K = [map[c] for c in key]
 n = len(K)
 C = [map[c] for c in msg]
 rv = ''.join([A[(((- K[(i % n)]) + c) % N)] for (i, c) in enumerate(C)])
 return rv

def decipher_vigenere ( msg , key , symbols = None ) : ( msg , key , A ) = _prep ( msg , key , symbols ) map = { c : i for ( i , c ) in enumerate ( A ) } N = len ( A ) K = [ map [ c ] for c in key ] n = len ( K ) C = [ map [ c ] for c in msg ] rv = '' . join ( [ A [ ( ( ( - K [ ( i % n ) ] ) + c ) % N ) ] for ( i , c ) in enumerate ( C ) ] ) return rv
decode using the vigenère cipher .