这个问题已经在这里得到解答: How to encrypt JSON in python
但是,我在使用加密模块时遇到错误。
raise TypeError("{} must be bytes".format(name)) TypeError: data must be bytes
这是我的代码:
from cryptography.fernet import Fernet
key= b'F9tdtAlS5kqVL5_uxKCnOPailXUqKsJmxbHWGLv_H-c='
with open('info.json', 'rb') as loader1:
params = json.load(loader1)
if xyz(x, y)==True:
fernet = Fernet(key)
encrypted=fernet.encrypt(params)
print(encrypted)
with open('info.json', 'wb') as writer1:
json.dump(encrypted, writer1)
print("Operation was a success")
else:
print("error")
吃鸡游戏
相关分类