You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
701 B
33 lines
701 B
|
|
from jmclient import Argon2Hash, get_random_bytes |
|
|
|
|
|
def test_argon2_sanity(): |
|
pwd = b'password' |
|
salt = b'saltsalt' |
|
|
|
h = Argon2Hash(pwd, salt, 16) |
|
|
|
assert len(h.hash) == 16 |
|
assert h.salt == salt |
|
assert h.hash == b'\x05;V\xd7fy\xdfI\xa4\xe7F$_\\3\xcb' |
|
|
|
|
|
def test_get_random_bytes(): |
|
assert len(get_random_bytes(16)) == 16 |
|
assert get_random_bytes(16) != get_random_bytes(16) |
|
|
|
|
|
def test_argon2(): |
|
pwd = b'testpass' |
|
h = Argon2Hash(pwd, hash_len=16, salt_len=22) |
|
|
|
assert len(h.hash) == 16 |
|
assert len(h.salt) == 22 |
|
|
|
h2 = Argon2Hash(pwd, h.salt, hash_len=16) |
|
|
|
assert h.settings == h2.settings |
|
assert h.hash == h2.hash |
|
assert h.salt == h2.salt |
|
|
|
|