You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am trying to create a custom field to implement client side encryption. I am able to perform serialisation during save, however I dont see a way to deserialise the data after a find (decrypt it). Is this possible by some means?
This is how I created the custom field
`class EncryptedFieldType(str):
@classmethod
def __get_validators__(cls):
yield cls.validate
@classmethod
def validate(cls, v):
if isinstance(v, bytes): # Handle data coming from MongoDB
print("In isinstance(v, bytes) ...")
return "hello"
if not isinstance(v, str):
raise TypeError("string required")
if not v.isascii():
raise ValueError("Only ascii characters are allowed")
return v
@classmethod
def __bson__(cls, v) -> str:
print("In __bson__")
return "*******"
class CollectionWithEncField(Model):
encrypted_field: EncryptedFieldType`
The text was updated successfully, but these errors were encountered:
Hi,
I am trying to create a custom field to implement client side encryption. I am able to perform serialisation during save, however I dont see a way to deserialise the data after a find (decrypt it). Is this possible by some means?
This is how I created the custom field
`class EncryptedFieldType(str):
class CollectionWithEncField(Model):
encrypted_field: EncryptedFieldType`
The text was updated successfully, but these errors were encountered: