From c16a4c8c9ea36c7dd4a511cff2c62bccd4384bb5 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 1 Nov 2019 14:38:41 +0100 Subject: 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) --- postgresqleu/auth.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'postgresqleu/auth.py') 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, -- cgit v1.2.3