many calls to nextRandom() could be saved in repeated calls to getrandbits when k<<256 by having a class variable to cache "leftover" bits rather than discarding (HASHLEN-k). Track the number of bits remaining, and call nextRandom() when the cache of bits is exhausted.
the current code will fail if k > HASHLEN.
many calls to nextRandom() could be saved in repeated calls to getrandbits when k<<256 by having a class variable to cache "leftover" bits rather than discarding (HASHLEN-k). Track the number of bits remaining, and call nextRandom() when the cache of bits is exhausted.