June 2020
Intermediate to advanced
382 pages
11h 39m
English
We will use Python's cryptography package, in this section, to demonstrate symmetric encryption. It is a comprehensive package that implements many cryptographic algorithms, such as symmetric ciphers and different message digests. When using it for the first time, we first need to install it using the pip command:
!pip install cryptography
Once installed, we can now use the package to implement symmetric encryption, as follows:
First, let's import the packages we need:
import cryptography as cryptfrom cryptography.fernet import Fernet
Let's generate the key:

Now, let's open the key:
file = open('mykey.key', ...