python fernet - decrypt exception InvalidToken - user login authentication

Viewed 36

I am trying to implement the solution (encryption of data with password) provided in the fernet docs under Using passwords with Fernet.

Since I would also like to use the same password for user login authentication I would like to know if it is safe to assume that if the encrypted data can't be decrypted with another (e.g. false) password, since I get the exception cryptography.fernet.InvalidToken, that also the user authentication failed because the provided password does not match the password used to encrypt the data?

In other words, do I need to check the authentication also using a separate logic with an implementation of a hashed password or can I rely solely on the fernet exception cryptography.fernet.InvalidToken for this?

0 Answers
Related