#!/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.")