Entropy devices such as /dev/random or /dev/urandom output data as sets of bytes. Sometimes, however, the entropy needed doesn't fall into nice byte boundaries so valuable entropy is wasted. On most systems, cryptographic quality entropy is a scarce resource.
This Python module provides two classes. EntropyBuffer returns any number of bits requested and saves extra entropy for the next call. Tools inherits from EntropyBuffer and provides useful functions such as selecting a random integer or shuffling a sequence. If /dev/random is used, these operations will be of cryptographic quality.
The code is still under development. The main thing missing is good test code which confirms that the outcomes are as evenly distributed as expected. It shouldn't be used for anything too important.
The current release is entropybuffer-0.1.tar.gz.