Last active
December 22, 2015 21:19
-
-
Save yankees714/6532423 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from string import ascii_lowercase | |
| plainText = "" | |
| cipherText = ( | |
| "JNRZR BNIGI BJRGZ IZLQR OTDNJ GRIHT USDKR ZZWLG OIBTM NRGJN IJTZJ LZISJ NRSBL QVRSI ORIQT" | |
| "QDEKJ JNRQW GLOFN IJTZX QLFQL WBIMJ ITQXT HHTBL KUHQL JZKMM LZRNT OBIMI EURLW BLQZJ GKBJT" | |
| "QDIQS LWJNR OLGRI EZJGK ZRBGS MJLDG IMNZT OIHRK MOSOT QHIJL QBRJN IJJNT ZFIZL WIZTO MURZM" | |
| "RBTRZ ZKBNN LFRVR GIZFL KUHIM MRIGJ LJNRB GKHRT QJRUU RBJLW JNRZI TULGI EZLUK JRUST QZLUK" | |
| "EURFT JNLKJ JNRXR S" | |
| ) | |
| # Table for cipher with self pairings to start | |
| cipher = {letter : "" for letter in ascii_lowercase} | |
| cipher[" "] = "" | |
| def set_letter_in_cipher(cipherLetter, plainLetter): | |
| cipher[cipherLetter.lower()] = plainLetter.lower() | |
| decryptedString = "" | |
| for letter in cipherText: | |
| decryptedLetter = letter.lower() | |
| if decryptedLetter in cipher and cipher[decryptedLetter]: | |
| decryptedLetter = cipher[decryptedLetter] | |
| elif letter is " ": | |
| decryptedLetter = " " | |
| else: | |
| decryptedLetter = "-" | |
| decryptedString = decryptedString + decryptedLetter | |
| plainText = decryptedString | |
| print "\n"+cipherText+"\n" | |
| print "\n"+plainText+"\n" | |
| def print_cipher(): | |
| print "\nCipher Letter | Plain Letter" | |
| print "----------------------------" | |
| for cipherLetter in cipher: | |
| if cipherLetter is not cipher[cipherLetter]: | |
| print " "+cipherLetter+" "+cipher[cipherLetter] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment