Skip to content

Instantly share code, notes, and snippets.

@reikoNeko
Created December 19, 2017 17:57
Show Gist options
  • Save reikoNeko/efde43b7aa2e308c143ec62a800359ae to your computer and use it in GitHub Desktop.
Save reikoNeko/efde43b7aa2e308c143ec62a800359ae to your computer and use it in GitHub Desktop.
def cryptogram(plaintext):
from random import shuffle
# create cryptogram cypher. You can't shuffle strings, so lists it is.
alpha = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
beta = alpha[:]
shuffle(beta)
cmap = dict(zip(alpha,beta))
# Map the received string to a cryptogram. Note we're not cleaning any input.
cryptext = [ cmap[c] if c in alpha else c for c in plaintext.upper()]
return ''.join(cryptext)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment