Pseudorandom Number Generator

PySkein contains a PRNG designed according to the Skein specification and based on Skein-512 by default. It is implemented in Python as a subclass of the standard library’s random.Random class and can therefore be used in the same way. The seed may be given as a bytes object:

>>> import skein
>>> r = skein.Random(b"some seed value")
>>> r.random()

or any other hashable object - in which case random.Random is used internally to derive a bytes seed:

>>> skein.Random(12345).random()

The same happens when no seed is given, so that the initial state is then derived from a suitable system source of randomness (like /dev/urandom or the time):

>>> r = skein.Random()
>>> r.random()

You may also directly read bytes or bits from the random stream:

>>> r = skein.Random(b"seed")
>>> r.getrandbits(4)

All other methods of skein.Random are based on random(). For their documentation please refer to the Python documentation.

Previous topic

Threefish block cipher

Next topic

Skein Stream Cipher

This Page