def key(self,text,enc):
		
		output = ""
		with open(text,'r+b') as f:
			with open(enc,'r+b') as f1:
				read_data = f.read(1)
				read_enc = f1.read(1)

			print "key = "+str( ( ord(read_enc) - ord(read_data)+256 ) % 256 )

			caesar = Caesar()
			test = caesar.decipher(enc,int( ( ord(read_enc) - ord(read_data)+256 ) % 256 ))
	def breakOpen(self,enc):

		it = 1
		key = it
		words = 0

		while it < 256:
			
			caesar = Caesar()
			file = caesar.decipher(enc,it)

			n = self.compare(file)

			if n > words:
				key = it
				words = n

			it += 1

		print key
Esempio n. 3
0
from caesar import Caesar
from transposition import Transposition
from vigenere import Vigenere
from substitution import Substitution

script,from_file,key,algorithm,option = argv


if algorithm == "c":

	caesar = Caesar()

	if option == "c":
		caesar.cipher(from_file,int(key))
	elif option == "d":
		caesar.decipher(from_file,int(key))
	else:
		print "Option doesn't exist."
elif algorithm == "t":

	transposition = Transposition()

	if option == "c":
		transposition.cipher(from_file,int(key))
	elif option == "d":
		transposition.decipher(from_file,int(key))
	else:
		print "Option doesn't exist."
elif algorithm == "v":

	vigenere = Vigenere()