0

我正在尝试将我的密码设置为 fernet 密钥并使用它来加密文本。

from cryptography.fernet import Fernet
fernet_master_pw = Fernet(master_pw)

在我的代码的第二行,我得到了这个错误:

    Traceback (most recent call last):
  File "C:\Users\Robin Groot\PycharmProjects\PasswordManager\main.py", line 68, in <module>
    fernet_master_pw = Fernet(master_pw)
  File "C:\Users\Robin Groot\PycharmProjects\PasswordManager\env\lib\site-packages\cryptography\fernet.py",
 line 37, in __init__
    key = base64.urlsafe_b64decode(key)
  File "C:\Program Files\Python39\lib\base64.py", line 133, in urlsafe_b64decode
    return b64decode(s)
  File "C:\Program Files\Python39\lib\base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Invalid base64-encoded string: number of data characters (5) cannot be 1 more than a multiple of 4

我已尝试搜索错误,但找不到答案。

4

0 回答 0