Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import cycle
- from string import ascii_lowercase
- a = 'abcdefghijklmnopqrstuvwxyz'
- b = 0x1A
- def encrypt(key, p):
- items = zip(p, cycle(key))
- result = ''
- for item in items:
- total = reduce(lambda u, v: a.index(u) + a.index(v), item)
- result += a[total % b]
- return result.lower()
- KEY='robinson'
- res = 'nsbzrlvrtvbucacaj'
- decrypt = 'a'*len(res)
- print decrypt
- for i in range(len(res)):
- for c in ascii_lowercase:
- s = list(decrypt)
- s[i] = c
- decrypt = "".join(s)
- cur_res = encrypt(KEY, decrypt)
- if cur_res[i] == res[i]:
- print decrypt
- break
- print "\nResult : {}".format(decrypt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement