這個問題已經在這里得到解答: How to encrypt JSON in python但是,我在使用加密模塊時遇到錯誤。raise TypeError("{} must be bytes".format(name))
TypeError: data must be bytes這是我的代碼:from cryptography.fernet import Fernetkey= 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")
如何在python中加密JSON,使用密碼學出錯
慕無忌1623718
2023-10-11 16:14:03