Example #1
0
class DocumentMovement(Schema):
    id = fields.UUID()
    document = fields.Str(required=True)
    value = fields.Float(required=True)
    input_type = fields.String(required=True)

    def __init__(self):
        super().__init__()
        self.cryp = Cryptography()

    def to_database(self, doc):
        doc['document'] = self.cryp.encrypt(doc['document'])

        return doc

    def from_database(self, doc):
        doc['document'] = self.cryp.decrypt(doc['document'])
        return doc
Example #2
0
class DocumentConsult(Schema):
    id = fields.UUID()
    document = fields.Str(required=True)
    company = fields.Str(required=True)
    consult_date = fields.Date(required=True)

    def __init__(self):
        super().__init__()
        self.cryp = Cryptography()

    def to_database(self, doc):
        doc['document'] = self.cryp.encrypt(doc['document'])
        doc['company'] = self.cryp.encrypt(doc['company'])
        return doc

    def from_database(self, doc):
        doc['document'] = self.cryp.decrypt(doc['document'])
        doc['company'] = self.cryp.decrypt(doc['company'])
        doc['consult_date'] = parse(doc['consult_date']).date()
        return doc
Example #3
0
class DocumentAcquisition(Schema):
    id = fields.UUID()
    document = fields.Str(required=True)
    value = fields.Float(required=True)
    store = fields.Str(required=True)

    def __init__(self):
        super().__init__()
        self.cryp = Cryptography()

    def to_database(self, doc):
        doc['document'] = self.cryp.encrypt(doc['document'])
        doc['store'] = self.cryp.encrypt(doc['store'])

        return doc

    def from_database(self, doc):
        doc['document'] = self.cryp.decrypt(doc['document'])
        doc['store'] = self.cryp.decrypt(doc['store'])
        return doc
Example #4
0
 def __init__(self):
     super().__init__()
     self.cryp = Cryptography()
Example #5
0
 def process_bind_param(self, value, dialect):
     if value:
         return Cryptography().encrypt(value)
     return None
Example #6
0
 def process_result_value(self, value, dialect):
     if value:
         if isinstance(value, (bytes, bytearray)):
             value = value.decode()
         return Cryptography().decrypt(value)
     return None