def to_python(self, value): value = super(CryptField, self).to_python(value) if value is not None: key = getattr(settings, 'SECRET_KEY') bc = BCipher(key) return bc.decrypt(value) return value
def get_prep_value(self, value): if value is not None and value != '': bc = BCipher() enc = bc.encrypt(value) else: enc = value return enc
def pre_save(self, model_instance, add): cleartext = getattr(model_instance, self.attname) key = getattr(settings, 'SECRET_KEY') bc = BCipher(key) enc = bc.encrypt(cleartext) setattr(model_instance, self.attname, enc) return enc
def to_python(self, value): value = super(CryptField, self).to_python(value) if value is not None and value != '': bc = BCipher() return bc.decrypt(value) return value
def _get_password(self): value = getattr(self, 'password') if value is not None: bc = BCipher() return bc.decrypt(value) return value
def _set_password(self, clear_text): bc = BCipher() setattr(self, 'password', bc.encrypt(clear_text))
def get_repo_pwd(self): value = getattr(self, 'repo_pwd') if value is not None: bc = BCipher() return bc.decrypt(value) return value
def set_repo_pwd(self, clear_text): bc = BCipher() setattr(self, 'repo_pwd', bc.encrypt(clear_text))