Exemplo n.º 1
0
    def read_data(self, n, d): 
        '''
        Reads in data from client to be sent and displayed to server.
        
        '''
        try:
            my_incoming_message = secure_utils.recv_end(self.my_connection)  # receive incoming data
            my_incoming_message = secure_utils.unpack_cipherblocks_from_transmit(my_incoming_message)  # unpack the combined cipher blocks
            my_incoming_message = RSA.decrypt(my_incoming_message, n, d, len([my_incoming_message]))  # decrypt the cipher

            while my_incoming_message.strip() != self.my_exit_code and len(my_incoming_message) > 0:
                print "\r\033[1;34m<< {0}\033[1;m".format(my_incoming_message.strip())
                my_incoming_message = secure_utils.recv_end(self.my_connection)  # continue receiving more messages
                my_incoming_message = secure_utils.unpack_cipherblocks_from_transmit(my_incoming_message)  # continue unpacking the cipher blocks
                my_incoming_message = RSA.decrypt(my_incoming_message, n, d, len([my_incoming_message]))  # continue decrypting
                # client disconnected
            self.stop_write_loop() 
        except:
            pass