SHA-based subclass for random module

Paul Rubin http
Mon Mar 22 22:27:59 EST 2004


Trevor Perrin <trevp_spam at trevp.net> writes:
> Actually, Random could be made even easier to subclass.  getrandbits
> (which is new in 2.4) returns a long.  It would be better for us if
> there was a getrandstring() function that an underlying generator
> could implement.  This would also be a helpful addition to the API, at
> least for cryptographic uses.

I agree with this, and was going to propose the same thing.
getrandbits can be defined easily in terms of getrandstring, and the
current sample sharandom implemenation at

   http://www.nightsong.com/phr/python/sharandom.py

does something along those lines.



More information about the Python-list mailing list