Created
June 8, 2015 02:00
-
-
Save rgov/6af0cebdf27b3592a5be to your computer and use it in GitHub Desktop.
This file contains 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
# for http://www.reddit.com/r/codes/comments/3874s7/crack_this_old_code_for_shiny_gold/ | |
# this is from source to InfoLock 5.5, http://sourceforge.net/projects/infolock | |
encoder_ring = { | |
'a': 8, 'b': 2, 'c': 3, 'd': 4, 'e': 7, 'f': 19, 'g': 5, 'h': 1, 'i': 9, | |
'j': 10, 'k': 29, 'l': 12, 'm': 24, 'n': 14, 'o': 15, 'p': 16, 'q': 25, | |
'r': 18, 's': 6, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 13, 'y': 17, | |
'z': 26, '!': 11, '?': 30, 'A': 31, 'B': 32, 'C': 33, 'D': 34, 'E': 35, | |
'F': 36, 'G': 37, 'H': 38, 'I': 39, 'J': 40, 'K': 41, 'L': 42, 'M': 43, | |
'N': 44, 'O': 45, 'P': 46, 'Q': 47, 'R': 48, 'S': 49, 'T': 50, 'U': 51, | |
'V': 52, 'W': 53, 'X': 54, 'Y': 55, 'Z': 56, ',': 57, '\'': 58, ':': 59, | |
'1': 60, '2': 61, '3': 62, '4': 63, '5': 64, '6': 65, '7': 66, '8': 67, | |
'9': 68, '0': 69, '<': 70, '>': 71, '/': 72, ';': 73, '@': 74, | |
'=': 27, '.': 28, | |
} | |
inv_encoder_ring = { v: k for k, v in encoder_ring.iteritems() } | |
inv_encoder_ring[27] = " " | |
passphrase = 'winstonn' | |
ciphertext = 'JnECqmFulkoxQyutMFMozuutlrKiEFzrlpFxHLvtVFCuHL' | |
plaintext = '' | |
for i, c in enumerate(ciphertext): | |
k = passphrase[i % len(passphrase)] | |
j = i / len(passphrase) | |
digr = encoder_ring.get(c, 0) | |
kdigr = encoder_ring.get(k, 0) | |
lr = digr - kdigr | |
plaintext += inv_encoder_ring.get(lr, '?') | |
print plaintext |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment