Files
Passgeny/tests/test_bhash.py
Mitja HORVAT bcae51ead9 c,python: Use little-endina byte order for bigint arithmetics
This better matches what one would expect from the hex or base64
(upcoming) formats.
2021-11-15 01:13:17 +01:00

23 lines
539 B
Python
Executable File

#!/usr/bin/env python3
import passgeny.bhash
import sys
TEST_STRING = b'hello world'
bh = passgeny.bhash.Bhash()
bh.from_bytes(TEST_STRING)
for c in TEST_STRING:
hc = bh.modulo(256)
if hc != c:
raise Exception("Returned value is {}, expected {}".format(chr(hc), c))
# This should throw an exception as we consumned all the bits in bhash
try:
bh.modulo(2)
except passgeny.bhash.BhashException as e:
print("Properly received exception: {}".format(e))
else:
raise Exception("Did not receive BhashException.")