This is code that's supposed to generate a cipher once, then prevent the cipher from being altered or viewed, but the code doesn't work. What's wrong with it?
from cryptography.fernet import Fernet
class Cipher:
def __init__(self, value=None):
self.cipher = Fernet(Fernet.generate_key())
@property
def cipher(self):
return self.__cipher
@cipher.setter
def cipher(self, value=None):
if not self.__cipher:
self.__init__()
else:
raise ValueError("Cipher may not be altered.")
def __repr__(self):
return "Cipher may not be viewed."
