只是尝试使用MultiFernet
.
我的代码是:
from cryptography.fernet import Fernet, MultiFernet
fetnet_keys = [
Fernet.generate_key(),
Fernet.generate_key()
]
mulfern = MultiFernet(fetnet_keys)
enc = mulfern.encrypt("My Message in Plain Text".encode('utf-8'))
print(enc)
尝试加密我得到的纯文本时:
Traceback (most recent call last):
File "encryption1.py", line 21, in <module>
enc = mulfern.encrypt("My Message in Plain Text".encode('utf-8'))
File "venv3.8\lib\site-packages\cryptography\fernet.py", line 169, in encrypt
return self.encrypt_at_time(msg, int(time.time()))
File "venv3.8\lib\site-packages\cryptography\fernet.py", line 172, in encrypt_at_time
return self._fernets[0].encrypt_at_time(msg, current_time)
AttributeError: 'bytes' object has no attribute 'encrypt_at_time'
解决方案是什么?