It is possible to use passwords with Fernet. To do this, you need to run the password through a key-derivation function, such as PBKDF2HMAC.
PBKDF2 (Password Based Key Derivation Function 2) is typically used for deriving a cryptographic key from a password.
In this example, we are using this function to generate a key from a password, and we use that key to create the Fernet object we will use for encrypting and decrypting data. In this case, the data to encrypt is a simple message string. We can use the verify() method, which checks whether deriving a new key ...