mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Meilleure gestion du AESField
This commit is contained in:
parent
f016882597
commit
6d335881a6
1 changed files with 1 additions and 4 deletions
|
@ -27,6 +27,7 @@ def encrypt(key, s):
|
|||
def decrypt(key, s):
|
||||
obj = AES.new(key)
|
||||
ss = obj.decrypt(s)
|
||||
print(ss)
|
||||
return ss.split(bytes(EOD, 'utf-8'))[0]
|
||||
|
||||
|
||||
|
@ -35,10 +36,6 @@ class AESEncryptedField(models.CharField):
|
|||
setattr(instance, self.name,
|
||||
binascii.b2a_base64(encrypt(settings.AES_KEY, data)))
|
||||
|
||||
def value_from_object(self, obj):
|
||||
return decrypt(settings.AES_KEY,
|
||||
binascii.a2b_base64(getattr(obj, self.attname))).decode('utf-8')
|
||||
|
||||
def to_python(self, value):
|
||||
if value is None:
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue