You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.0 KiB

import os
import random
from pyelliptic.openssl import OpenSSL
NoneType = type(None)
def randomBytes(n):
"""Method randomBytes."""
return os.urandom(n)
except NotImplementedError:
return OpenSSL.rand(n)
def randomshuffle(population):
"""Method randomShuffle.
shuffle the sequence x in place.
shuffles the elements in list in place,
so they are in a random order.
return random.shuffle(population)
def randomsample(population, k):
"""Method randomSample.
return a k length list of unique elements
chosen from the population sequence.
Used for random sampling
without replacement
return random.sample(population, k)
def randomrandrange(x, y=None):
"""Method randomRandrange.
return a randomly selected element from
range(start, stop). This is equivalent to
choice(range(start, stop)),
but doesnt actually build a range object.
if isinstance(y, NoneType):
return random.randrange(x)
return random.randrange(x, y)