refactor: untangle lnd's macaroon encryption with AESCipher class (#3152)
This commit is contained in:
parent
7bea591879
commit
3b350858c7
7 changed files with 207 additions and 124 deletions
20
tests/unit/test_crypto_aes.py
Normal file
20
tests/unit/test_crypto_aes.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import pytest
|
||||
|
||||
from lnbits.utils.crypto import AESCipher
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@pytest.mark.parametrize(
|
||||
"key",
|
||||
[
|
||||
"normal_string",
|
||||
b"normal_bytes",
|
||||
b"hex_string".hex(),
|
||||
],
|
||||
)
|
||||
async def test_aes_encrypt_decrypt(key):
|
||||
aes = AESCipher(key)
|
||||
original_text = "Hello, World!"
|
||||
encrypted_text = aes.encrypt(original_text.encode())
|
||||
decrypted_text = aes.decrypt(encrypted_text)
|
||||
assert original_text == decrypted_text
|
||||
Loading…
Add table
Add a link
Reference in a new issue