Remove old Python 2 compatibility code. Fixes #5700

This commit is contained in:
Cyril Jouve
2020-07-27 11:03:13 +01:00
committed by Dave Page
parent 7a22cff28c
commit f93cfe8c4c
197 changed files with 47 additions and 354 deletions

View File

@@ -9,14 +9,10 @@
"""This File Provides Cryptography."""
from __future__ import division
import base64
import hashlib
import os
import six
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import Cipher
from cryptography.hazmat.primitives.ciphers.algorithms import AES
@@ -41,7 +37,7 @@ def encrypt(plaintext, key):
# If user has entered non ascii password (Python2)
# we have to encode it first
if isinstance(plaintext, six.text_type):
if isinstance(plaintext, str):
plaintext = plaintext.encode()
return base64.b64encode(iv + encryptor.update(plaintext) +
@@ -68,7 +64,7 @@ def decrypt(ciphertext, key):
def pad(key):
"""Add padding to the key."""
if isinstance(key, six.text_type):
if isinstance(key, str):
key = key.encode()
# Key must be maximum 32 bytes long, so take first 32 bytes