Merge pull request #21694 from edx/awais786/BOM-437

BOM-437
This commit is contained in:
Awais Qureshi
2019-09-19 20:03:38 +05:00
committed by GitHub

View File

@@ -64,6 +64,10 @@ class UsernameCipher(object):
@staticmethod
def encrypt(username):
initialization_vector = os.urandom(AES_BLOCK_SIZE_BYTES)
if not isinstance(initialization_vector, (bytes, bytearray)):
initialization_vector = initialization_vector.encode('utf-8')
aes_cipher = UsernameCipher._get_aes_cipher(initialization_vector)
encryptor = aes_cipher.encryptor()
padder = PKCS7(AES.block_size).padder()