Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_cipherType(ciphertext):
- if len(ciphertext) == 0:
- return 'Empty Ciphertext'
- polybius = True
- polybius_count =0
- for i in ciphertext:
- if i =='\n':
- continue
- else:
- try:
- int(i)
- polybius_count+=1
- except:
- polybius = False
- break
- if (polybius and (polybius_count%2==0)):
- return 'Polybius Square Cipher'
- ic = get_indexOfCoin(remove_nonalpha(ciphertext))
- chi_squared = utilities_A2.get_chiSquared(remove_nonalpha(ciphertext))
- if (chi_squared < 400):
- return 'Spartan Scytale Cipher'
- else:
- modified_ciphertext = ''
- for i in ciphertext:
- if i.isalpha():
- modified_ciphertext+=chr(ord('Z') - ord(i.upper())+65)
- else:
- modified_ciphertext+=i
- chi_squared_possible_atbash = utilities_A2.get_chiSquared(remove_nonalpha(modified_ciphertext))
- if (ic>=0.062 and ic<=0.068 and chi_squared_possible_atbash<150):
- return 'Atbash Cipher'
- elif(ic>=0.062 and ic<=0.068):
- return 'Shift Cipher'
- elif(ic>=0.0415 and ic<=0.062):
- return 'Vigenere Cipher'
- return 'Unknown'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement