In cryptography, a key is a combination of numbers that is used to encode plain text using an algorithm of our choice. In symmetric encryption, we use the same key for encryption and decryption. If the key used for symmetric encryption is K, then for symmetric encryption, the following equation holds:
EK(P) = C
Here, P is the plain text and C is the cipher text.
For decryption, we use the same key, K, to convert it back to P:
DK(C) = P
This process is shown in the following diagram:
Now, let's look at how we can use symmetric encryption with Python.