I wanted to create a program where i could make some encryption, then send it to a friend, and then send him the encryption key and the decryption code and then he could decrypt the message himself. I have only figured out how to decrypt something based on the encryption, this is my attempt:
import cryptography
from cryptography.fernet import Fernet
key = Fernet.generate_key()
print(key)
with open("pass.key", "wb") as key_file: key_file.write(key)
def call_key():
return open("pass.key", "rb").read()
key = call_key()
code = "Hello!! Awesome code!!".encode()
a = Fernet(key)
code = a.encrypt(code)
print(code)
key = call_key()
b = Fernet(key)
decoded_code = b.decrypt(code)
print(decoded_code)
The problem is for this to work the encrypted part has to be known. i want it so that it can be decrypted without knowing the original message. Thanks for your help:)