Is a symmetric encryption key derivable using the input and the output? I am looking for a python library for encrypting a string with a single key. I do not want the key to derivable by knowing the input and the output. I have came to cryptography.fernet so far, but I am not sure if this will fulfill my needs. Can the encryption key be derived by knowing the algorithm (assuming the fernet algorithm in this case) and knowing the input and the output?

For example when I encrypt message A with key K and it outputs B, can somehow A and B be put together, so it will output K?

EDIT

The actual use of this is the following. I need to store a password in a place that others can see (a discord config channel, but that is secondary) in a way so they cannot see the actual password. I thought that the user would encrypt the password one-time with a key only visible to the bot (a discord bot) (with a command). The encrypted password would then be sent back to the user and stored in the channel for the bot to decrypt it and use it later. The problem is: if the user knows the input and the output, if he would be able to guess the key, he would then be able to decrypt all other passwords stored this way. And absolutely noone wants this to happen!
For example when I encrypt message A with key K and it outputs B, can somehow A and B be put together, so it will output K?


Except for encryption messages where you are specifically restricted to use a specifc key K only once (e.g. OTP), then no, it is infeasible to recover K from A and B.

This is a fairly fundamental requirement on encryption methods (known as "Known Plaintext"); that is, given a plaintext message and the corresponding ciphertext (or more generally, a huge number of messages and ciphertexts, all encrypted with the same key), that is still no help in decrypting another ciphertext (also encrypted with the same key) - being able to recover the key from a plaintext and ciphertext would violate this.

Actually, we put even tougher requirements on encryption methods.  We allow the attacker to pick the messages to be encrypted ("Chosen Plaintext"), and also allow the attacker to submit his own ciphertexts (and see how they are decrypted), "Chosen Ciphertext".

An encryption method is generally not considered secure unless it is secure against all these attack scenarios.