Skip to content
Advertisement

cryptography.fernet.InvalidToken problem with cryptography

Getting this error when trying to run this:

JavaScript

FYI dk variable is defined with key (default key)

JavaScript

Edit: I added the key for those who asked

Advertisement

Answer

I have found out, through trial and error with the same project later down the line, that you need to turn your key into something like this key = b'niwaXsYbDiAxmLiqRiFbDa_8gHio15sNQ6ZO-sQ0nR4='

The main difference being the key is encoded in a utf-8 format and is now readable by Fernet and doesn’t return that error. Here is a function that uses Tkinter, Fernet, and os to actually decrypt my file.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement