Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nounous
re2o
Commits
193dfb67
Commit
193dfb67
authored
Jul 04, 2018
by
Hugo LEVY-FALK
Browse files
Cache le mot de passe de paiement comnpay
parent
2aaf83d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
cotisations/payment_methods/comnpay/aes_field.py
View file @
193dfb67
...
...
@@ -7,6 +7,7 @@
# Copyright © 2017 Goulven Kermarec
# Copyright © 2017 Augustin Lemesle
# Copyright © 2018 Maël Kervella
# Copyright © 2018 Hugo Levy-Falk
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
...
...
@@ -22,10 +23,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# App de gestion des machines pour re2o
# Gabriel Détraz, Augustin Lemesle
# Gplv2
"""preferences.aes_field
"""
Module defining a AESEncryptedField object that can be used in forms
to handle the use of properly encrypting and decrypting AES keys
"""
...
...
@@ -36,6 +34,7 @@ from random import choice
from
Crypto.Cipher
import
AES
from
django.db
import
models
from
django
import
forms
from
django.conf
import
settings
EOD
=
'`%EofD%`'
# This should be something that will not occur in strings
...
...
@@ -66,6 +65,10 @@ def decrypt(key, s):
return
ss
.
split
(
bytes
(
EOD
,
'utf-8'
))[
0
]
class
AESEncryptedFormField
(
forms
.
CharField
):
widget
=
forms
.
PasswordInput
(
render_value
=
True
)
class
AESEncryptedField
(
models
.
CharField
):
""" A Field that can be used in forms for adding the support
of AES ecnrypted fields """
...
...
@@ -92,3 +95,8 @@ class AESEncryptedField(models.CharField):
settings
.
AES_KEY
,
value
))
def
formfield
(
self
,
**
kwargs
):
defaults
=
{
'form_class'
:
AESEncryptedFormField
}
defaults
.
update
(
kwargs
)
return
super
().
formfield
(
**
defaults
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment