#!/usr/bin/env python3 import passgeny.bhash import sys TEST_STRING = b'hello world' bh = passgeny.bhash.Bhash() bh.from_bytes(TEST_STRING) # Scan the string in reverse order (::-1) as bhash should use big endian arithmetics for c in TEST_STRING[::-1]: 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.")