Python Forum
problem with "hiding" object
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with "hiding" object
#1
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."
Reply


Messages In This Thread
problem with "hiding" object - by league55 - Jan-16-2018, 07:30 PM
RE: problem with "hiding" object - by buran - Jan-16-2018, 08:41 PM
RE: problem with "hiding" object - by league55 - Jan-16-2018, 09:44 PM
RE: problem with "hiding" object - by wavic - Jan-16-2018, 10:32 PM
RE: problem with "hiding" object - by league55 - Jan-16-2018, 11:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Hiding username and password on sql tantony 10 3,121 Oct-21-2022, 07:58 PM
Last Post: wavic
  Hiding "undesired" info Extra 4 1,863 Jan-03-2022, 08:25 PM
Last Post: Extra
Lightbulb Object Oriented programming (OOP) problem OmegaRed94 6 3,012 May-31-2021, 07:19 PM
Last Post: OmegaRed94
  Please help! Problem with my Point object itrema 2 5,322 Mar-05-2019, 09:57 AM
Last Post: itrema

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020