def receive(self): receivedmessage = self.s.recv(1024) receivedmessage = methods.decrypt(receivedmessage) print(receivedmessage) return json.loads(receivedmessage)
encrypted_file = splitted_message[0] encrypted_certificate = splitted_message[1] hashed_file = splitted_message[2] time = splitted_message[5] expiry = splitted_message[6] time_now = datetime.datetime.now(); decrypted_certificate = "" for i in range(2,6): decrypted_certificate += splitted_message[i] + "||" decrypted_certificate += splitted_message[6] if methods.decrypt(encrypted_certificate, Public_Key_TSA) != methods.hash_string(decrypted_certificate): print("Invalid Certificate") continue file = methods.decrypt(encrypted_file, key[1]) if hashed_file != methods.hash_string(file): print("File Incorrect") continue if datetime.datetime.strptime(expiry, '%Y-%m-%d %H:%M:%S.%f') < time_now: print("Expiry Certificate") continue else: print("Expiry Time", datetime.datetime.strptime(expiry, '%Y-%m-%d %H:%M:%S.%f')) print("Current Time", time_now) print(file)
splitted_message = message_from_tsa.split("||") encrypted_hash = splitted_message[0] hashed_file = splitted_message[1] time = splitted_message[4] expiry = splitted_message[5] message_to_be_checked = "" for i in range(1, 5): message_to_be_checked += splitted_message[i] + "||" message_to_be_checked += splitted_message[5] decrypted_hash = methods.decrypt(encrypted_hash, PublicKey_TSA) s.close() if decrypted_hash == methods.hash_string(message_to_be_checked): break else: splitted_message = message_from_tsa.split("||") encrypted_hash = splitted_message[0] hashed_file = splitted_message[1] time = splitted_message[4] expiry = splitted_message[5] message_to_be_checked = "" for i in range(1, 5):
def receive(self): message = self.connection.recv(4096) message = methods.decrypt(message) methods.print_log('robot - {}'.format(message)) #might remove the replace if using minimalistic json convertion return json.loads(message)