Skip to content

Instantly share code, notes, and snippets.

View suspectpart's full-sized avatar
🐍
Python for Dummies - Out now!

Horst Schneider suspectpart

🐍
Python for Dummies - Out now!
  • Universität Heidelberg, Germany
  • Mannheim
View GitHub Profile
anonymous
anonymous / Vigener Cypher
Created June 27, 2013 23:26
import string
def vigener_cypher(key, message):
alphabet = string.lowercase
key *= (len(message) // len(key)) + 1
translate = lambda x: [alphabet.index(c) for c in x]
message, key = translate(message), translate(key)
cypher = [(pair[0] + 1 + pair[1]) % 26 for pair in zip(key, message)]
cypher = map(lambda c: alphabet[c], cypher)
return ''.join(cypher)