コード例 #1
0
 def write_data(self, n, e):
     '''
     Reads in data from prompt and sending out to client 
     ''' 
     try:
         
         while self.my_continue_to_write:
             my_original_message = sys.stdin.readline()  # read input from user
             my_outgoing_message = RSA.encrypt(my_original_message, n, e, len([my_original_message]))  # encrypt the users input
             
             my_outgoing_message = secure_utils.combine_cipherblocks_for_transmit(my_outgoing_message) + ";;"  # add the ";;" delimeter. This indicates the end of a user's input. A fix for not knowing the buffer size. 
             self.my_connection.send(my_outgoing_message)  # send out message to the user.
         
             # check to see if my outgoing message is EXIT to quit the chat
             if (my_original_message.strip() == self.my_exit_code):
                 self.my_connection.shutdown(socket.SHUT_RDWR)
                 self.my_connection.close()
                 self.stop_write_loop()
     except:
         pass