summaryrefslogtreecommitdiff
path: root/postgresqleu/auth.py
diff options
context:
space:
mode:
authorMagnus Hagander2019-11-01 13:38:41 +0000
committerMagnus Hagander2019-11-01 13:38:41 +0000
commitc16a4c8c9ea36c7dd4a511cff2c62bccd4384bb5 (patch)
tree5638e8f7983a2afb53b9c9310b16057af2db4a6b /postgresqleu/auth.py
parentb247e70c87e17b0f2b3d7e7d2452c17dded9ebaa (diff)
Switch to using pycryptodome instead of pycrypto
pycrypto is not being maintained, and pycryptodome is theoretically a drop-in replacement (in practice, it seems it was close)
Diffstat (limited to 'postgresqleu/auth.py')
-rw-r--r--postgresqleu/auth.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/postgresqleu/auth.py b/postgresqleu/auth.py
index e8daa0ba..f90b1b13 100644
--- a/postgresqleu/auth.py
+++ b/postgresqleu/auth.py
@@ -30,9 +30,9 @@ import json
import socket
from urllib.parse import urlparse, urlencode, parse_qs
import requests
-from Crypto.Cipher import AES
-from Crypto.Hash import SHA
-from Crypto import Random
+from Cryptodome.Cipher import AES
+from Cryptodome.Hash import SHA
+from Cryptodome import Random
import time
@@ -58,7 +58,7 @@ def login(request):
r = Random.new()
iv = r.read(16)
encryptor = AES.new(SHA.new(settings.SECRET_KEY.encode('ascii')).digest()[:16], AES.MODE_CBC, iv)
- cipher = encryptor.encrypt(s + ' ' * (16 - (len(s) % 16))) # pad to 16 bytes
+ cipher = encryptor.encrypt(s.encode('ascii') + b' ' * (16 - (len(s) % 16))) # pad to 16 bytes
return HttpResponseRedirect("%s?d=%s$%s" % (
settings.PGAUTH_REDIRECT,