Skip to content

Instantly share code, notes, and snippets.

@saurabhwahile
Created December 12, 2014 06:40
Show Gist options
  • Save saurabhwahile/98eeb2ab8363c9189b21 to your computer and use it in GitHub Desktop.
Save saurabhwahile/98eeb2ab8363c9189b21 to your computer and use it in GitHub Desktop.
Analyse Substitution Cipher
from string import ascii_lowercase
ITERATIONS = 3
charMapping = {}
charControl = 0
for char in ascii_lowercase:
charMapping[charControl] = char
charControl+=1
CODE = 'VHFXULWB'
CODE = CODE.lower()
def applyIteration(code, key):
print 'Key='+str(key)
result = ''
for char in code:
result = result + charMapping[(ascii_lowercase.find(char)+key)%26]
print result
for key in range(26):
applyIteration(CODE, key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment