INNER CODE UNIT · Python

__getattr__

kurtbrose/pyjks · jks/bks.py:148

    def __getattr__(self, name):
        if not self.is_decrypted():
            raise NotYetDecryptedException("Cannot access attribute '%s'; entry not yet decrypted, call decrypt() with the correct password first" % name)
        # if it's an attribute that exists here, return it; otherwise forward the request to the nested entry
        if "_"+name in self.__dict__:
            return self.__dict__["_"+name]
        else:
            return getattr(self._nested, name)

    def is_decrypted(self):
        return (not self._encrypted)

    def decrypt(self, key_password):
        if self.is_decrypted():
            return

        pos = 0
        data = self._encrypted

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…