1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| import re Str = ‘………..’ arr = re.findall('.{5}', str) alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] first_cipher = ["aaaaa","aaaab","aaaba","aaabb","aabaa","aabab","aabba","aabbb","abaaa","abaab","ababa","ababb","abbaa","abbab","abbba","abbbb","baaaa","baaab","baaba","baabb","babaa","babab","babba","babbb","bbaaa","bbaab"] second_cipher = ["aaaaa","aaaab","aaaba","aaabb","aabaa","aabab","aabba","aabbb","abaaa","abaaa","abaab","ababa","ababb","abbaa","abbab","abbba","abbbb","baaaa","baaab","baaba","baabb","baabb","babaa","babab","babba","babbb"]
keyword1 = "" keyword2 = "" keyword3 = "" keyword4 = "" for one in arr: toab1 = "" toab2 = "" for i in one: if i.isupper(): toab1 += 'b' toab2 += 'a' else: toab1 += 'a' toab2 += 'b'
for local,ab in enumerate(first_cipher): if ab == toab1: keyword1 += alphabet[local] if ab == toab2: keyword3 += alphabet[local]
for local,ab in enumerate(second_cipher): if ab == toab1: keyword2 += alphabet[local] if ab == toab2: keyword4 += alphabet[local]
print(keyword1) print(keyword2) print(keyword3) print(keyword4)
|