def get_db_prep_value(self, value, connection=None, prepared=False):
        if value is None:
            return None

        value = smart_str(value)

        if not self._is_encrypted(value):
            padding = self._get_padding(value)
            if padding > 0:
                value += "\0" + ''.join([
                    random.choice(string.printable)
                    for index in range(padding-1)
                ])
            if self.block_type:
                self.cipher = self.cipher_object.new(
                    self.secret_key,
                    getattr(self.cipher_object, self.block_type),
                    self.iv)
                value = self.prefix + binascii.b2a_hex(self.iv + self.cipher.encrypt(value))
            else:
                value = self.prefix + binascii.b2a_hex(self.cipher.encrypt(value))
        return value
dataset/ETHPy150Open svetlyak40wt/django-fields/src/django_fields/fields.py/BaseEncryptedField.get_db_prep_value/original