def key(self,text,enc): dict = {} with open(text,'r+b') as f: with open(enc,'r+b') as f1: while 1: read_data = f.read(1) read_enc = f1.read(1) if not read_data: break dict[ ord( read_data ) ] = ord( read_enc ) output = open("substituition_key.txt",'w+b') for key, value in dict.items(): output.write( chr( key ) ) output.write( chr( value ) ) output.write( "\n" ) output.flush() output.close() substitution = Substitution() test = substitution.decipher(enc,"substituition_key.txt")
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() if option == "c": vigenere.cipher(from_file,key) elif option == "d": vigenere.decipher(from_file,key) else: print "Option doesn't exist." elif algorithm == "s": substitution = Substitution() if option == "c": substitution.cipher(from_file,key) elif option == "d": substitution.decipher(from_file,key) else: print "Option doesn't exist." else: print "Algorithm doesn't exist."