2 changed files with 0 additions and 33 deletions
@ -1,7 +0,0 @@ |
|||||
{% extends 'base.html' %} |
|
||||
{% block content %} |
|
||||
<form action="" method="post">{% csrf_token %} |
|
||||
{{ form.as_p }} |
|
||||
<input type="submit" value="Sauvegarder" /> |
|
||||
</form> |
|
||||
{% endblock %} |
|
||||
@ -1,26 +0,0 @@ |
|||||
import string |
|
||||
from random import choice |
|
||||
from Crypto.Cipher import AES |
|
||||
|
|
||||
EOD = '`%EofD%`' # This should be something that will not occur in strings |
|
||||
|
|
||||
|
|
||||
def genstring(length=16, chars=string.printable): |
|
||||
return ''.join([choice(chars) for i in range(length)]) |
|
||||
|
|
||||
|
|
||||
def encrypt(key, s): |
|
||||
obj = AES.new(key) |
|
||||
datalength = len(s) + len(EOD) |
|
||||
if datalength < 16: |
|
||||
saltlength = 16 - datalength |
|
||||
else: |
|
||||
saltlength = 16 - datalength % 16 |
|
||||
ss = ''.join([s, EOD, genstring(saltlength)]) |
|
||||
return obj.encrypt(ss) |
|
||||
|
|
||||
|
|
||||
def decrypt(key, s): |
|
||||
obj = AES.new(key) |
|
||||
ss = obj.decrypt(s) |
|
||||
return ss.split(EOD)[0] |
|
||||
Loading…
Reference in new issue