diff --git a/communication/client.py b/communication/client.py
index cc42b438363e62d8ccbb555b88b253b80874bbf4..fa78ebc2b75af8673f8d27bc5509d70e3fbec5a9 100644
--- a/communication/client.py
+++ b/communication/client.py
@@ -22,7 +22,9 @@ def load_public_key():
 def encrypt_key_with_rsa(public_key, key):
     cipher = PKCS1_OAEP.new(public_key)
     encrypted_key = cipher.encrypt(key)
-    return encrypted_key
+    encrypted_key_base64 = base64.b64encode(encrypted_key).decode('utf-8')
+    return encrypted_key_base64
+
 
 # Encrypt entered user message according to selected algorithm and key length
 def encrypt_message(algorithm, key, message):
diff --git a/communication/server.py b/communication/server.py
index ddbb7f95e1263de9745d74a9e37a5b4863733674..0e769f3541467eee3c08edaf326953446cda33f8 100644
--- a/communication/server.py
+++ b/communication/server.py
@@ -18,12 +18,14 @@ def load_private_key():
     return private_key
 
 # Decrypt the received key using RSA private key
-def decrypt_key_with_rsa(private_key, encrypted_key):
+def decrypt_key_with_rsa(private_key, encrypted_key_base64):
+    encrypted_key = base64.b64decode(encrypted_key_base64)
     cipher = PKCS1_OAEP.new(private_key)
     key = cipher.decrypt(encrypted_key)
     logging.info(f"Decrypted RSA key: {key.hex()}")
     return key
 
+
 # Decrypt received message using the key, depending on algorithm
 def decrypt_message(algorithm, key, encrypted_message):
     logging.info(f"Starting decryption with algorithm: {algorithm}")