Skip to content
Snippets Groups Projects
Commit 6b82a635 authored by Dominik Fuhrmann's avatar Dominik Fuhrmann
Browse files

possible fix for base64

parent 6df2d03d
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......
......@@ -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}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment