def send_command(self, data):
     # Send data to server
     try:
         encrypted_data = encrypt(data.encode())
         self.CLIENT.sendall(encrypted_data)
     except socket.error as e:
         print(str(e))
Beispiel #2
0
def send_gamestate(gamestate, connection):
    # Send gamestate as serialized pickle object
    gamestate_pickle = pickle.dumps(gamestate)
    try:
        encrypted_data = encrypt(gamestate_pickle)
        connection.sendall(encrypted_data)
    except socket.error as e:
        print(str(e))
 def send_pickle(self, data):
     # Send move or attack to server
     data_pickle = pickle.dumps(data)
     try:
         encrypted_data = encrypt(data_pickle)
         self.CLIENT.sendall(encrypted_data)
     except socket.error as e:
         print(str(e))
Beispiel #4
0
def send_data(data, connection):
    try:
        encrypted_data = encrypt(str(data).encode())
        connection.sendall(encrypted_data)
    except socket.error as e:
        print("[Error]: Socket cannot be used to send data.")
        print(str(e))
    except TypeError:
        print("[Error]: Data cannot be converted to string to be sent.")
 def send_pickle(self, data):
     """
     Sends a serialized object to server.
     """
     data_pickle = pickle.dumps(data)
     try:
         encrypted_data = encrypt(data_pickle)
         self.CLIENT.sendall(encrypted_data)
     except socket.error as e:
         print(str(e))
 def send_command(self, data):
     """
     Sends a command the server understands, such
     as requesting data or letting the server know
     that the client is about to send data.
     """
     try:
         encrypted_data = encrypt(data.encode())
         self.CLIENT.sendall(encrypted_data)
     except socket.error as e:
         print(str(e))
Beispiel #7
0
 def update_password(self, password):
     self.password = encrypt(password)
     return self._commit("user password:")
Beispiel #8
0
 def __init__(self, username, email, first_name, last_name, password):
     self.username = username
     self.email = email
     self.first_name = first_name
     self.last_name = last_name
     self.password = encrypt(password)
Beispiel #9
0
from src.encryption import encrypt, decrypt
key = '10:20:30:40:50'
text = 'Hello! This is example of my encryption.'
print(text, len(text))
encryptedText = encrypt(key, text)
print(encryptedText, len(encryptedText))
decryptedText = decrypt(key, encryptedText)
print(decryptedText, len(decryptedText))