def send(self, message):
     jsonmessage = json.dumps(message)
     print(jsonmessage)
     encryptedmessage = methods.encrypt(jsonmessage)
     self.s.send(encryptedmessage)
示例#2
0
    hashed_file_from_A = c.recv(2048).decode()
    time = datetime.datetime.now()
    expiry = time + datetime.timedelta(0, 300)

    message = hashed_file_from_A + "||" + str(A_ID) + "||" + str(
        time) + "||" + str(expiry)

    # print("message",message)

    # print(message,"---")

    hash_to_be_sent = methods.hash_string(message)

    # print(hash_to_be_sent)
    # hash_to_be_sent = str.encode(hash_to_be_sent)
    encrypted_hash_to_be_sent = methods.encrypt(hash_to_be_sent, PrivateKey)
    # print(type(encrypted_hash_to_be_sent))
    # encrypted_hash_to_be_sent = str.encode(encrypted_hash_to_be_sent)
    # encrypted_hash_to_be_sent = key.encrypt(hash_to_be_sent, 32)

    # byte_message = str.encode(encrypted_hash_to_be_sent+"||"+message)
    # byte_message += listOfPublicKeys[B_ID].exportKey("PEM") + str.encode("||")
    # byte_message += PublicKey.exportKey("PEM")

    # print(byte_message)
    # print("---------")
    # print(PublicKey.exportKey("PEM"))

    c.send(str.encode(encrypted_hash_to_be_sent + "||" + message))
s.close()
示例#3
0
# print(decrypted_hash==methods.hash_string(hash_to_be_checked))








#####################################################################################

'''
Communication between A and B
'''

s = socket.socket()
port = port2 
s.connect(('127.0.0.1', port))
# time_now = datetime.datetime.now()
encrypted_file = methods.encrypt(file, PublicKey_B)
message = encrypted_file + "||" + message_from_tsa
# message = 'from A to B' + '||' + str(time_now)
s.send(str.encode(message))
s.close()





示例#4
0
 def sent(self, message):
     message = json.dumps(message, separators=(',',':'))
     methods.print_log('server - {}'.format(message))
     
     message = methods.encrypt(message)
     self.connection.sendall(message)