def test_aes_rand(): key = rand(32) cipher1 = AES(key=key) ciphertext = cipher1.encrypt(TEST_TEXT) cipher2 = AES(key=key) assert cipher2.decrypt(ciphertext) == TEST_TEXT
def test_aes_passphrase(): passphrase = b"the most secret passphrase ever" cipher1 = AES(passphrase=passphrase) ciphertext = cipher1.encrypt(TEST_TEXT) cipher2 = AES(passphrase=passphrase) assert cipher2.decrypt(ciphertext) == TEST_TEXT
def test_aes_exception(): passphrase = b"the most secret passphrase ever" cipher1 = AES(passphrase=passphrase) ciphertext = cipher1.encrypt(TEST_TEXT) cipher2 = AES(passphrase="wrong one") with pytest.raises(WrongKeyError): cipher2.decrypt(ciphertext)
def test_utilities(): AES256Encrypter.register_class(default=True) init_crypto(passphrase="Hello world") test_text = b"Test text " * 100 encrypted_text = encrypt(test_text) assert encrypted_text.startswith(b".e") assert decrypt(encrypted_text) == test_text