python3: encodinging variations in authentic2.crypto aes testing

This commit is contained in:
Paul Marillonnet 2020-02-06 13:32:31 +01:00
parent cabb3476b0
commit 39934817e9
1 changed files with 6 additions and 3 deletions

View File

@ -20,14 +20,17 @@ import uuid
import time
import pytest
from django.utils.encoding import force_bytes
from authentic2 import crypto
key = '1234'
key = b'1234'
def test_idempotency():
for i in range(10):
s = str(random.getrandbits(1024))
s = force_bytes(str(random.getrandbits(1024)))
assert crypto.aes_base64_decrypt(key, crypto.aes_base64_encrypt(key, s)) == s
@ -50,7 +53,7 @@ def test_padding():
def test_deterministic_encryption():
salt = '4567'
salt = b'4567'
raw = uuid.uuid4().bytes
for hash_name in ['md5', 'sha1', 'sha256', 'sha384', 'sha512']: