• File: random.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/site-packages/Crypto/Random/__pycache__/random.cpython-37.pyc
  • Date Modified: 01/31/2023 11:01 AM
  • File size: 3.46 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

cs@sdZdZdddddddgZd	d
lmZd	dlZejd	dkrRejd
d
krRd	dlTGdddeZ	e	Z
e
jZe
jZe
j
Z
e
jZe
jZe
jZd	dlmZmZmZmZdS)zHA cryptographically strong version of Python's standard "random" module.z$Id$StrongRandomgetrandbits	randrangerandintchoiceshufflesample)RandomN)*c@sFeZdZdddZddZddZdd	Zd
dZdd
ZddZ	dS)rNcCsV|dkr|dkrd|_n:|dk	r0|dkr0||_n"|dkrJ|dk	rJ|j|_ntddS)Nz(Cannot specify both 'rng' and 'randfunc')	_randfuncread
ValueError)selfrngZrandfuncrG/opt/alt/python37/lib64/python3.7/site-packages/Crypto/Random/random.py__init__$s
zStrongRandom.__init__cCs:|jdkrtj|_d|>d}|t|t|d@S)z0Return a python long integer with k random bits.Nr)r
r	newr
bytes_to_longceil_div)rkmaskrrrr.s
zStrongRandom.getrandbitscGst|dkr|\}}}nHt|dkr2|\}}d}n.t|dkrN|\}d}d}ntdt|ft|tr~t|tr~t|tstd|dkrtdt|||}|dkrd}|dkrtd|||f|}x||kr|t|}qW|||S)	zkrandrange([start,] stop[, step]):
        Return a randomly-selected element from range(start, stop, step).r
rrz.randrange expected at most 3 arguments, got %dz$randrange requires integer argumentsz(randrange step argument must not be zeroz%empty range for randrange(%r, %r, %r))len	TypeError
isinstanceintrrrsize)rargsstartstopstepnum_choicesrrrrr5s2



zStrongRandom.randrangecCsJt|trt|tstd|||d}||kr@|ksFnt|S)z0Return a random integer N such that a <= N <= b.z"randint requires integer argumentsr)rrrrAssertionError)rabNrrrrWs
zStrongRandom.randintcCs&t|dkrtd||t|S)zrReturn a random element from a (non-empty) sequence.

        If the seqence is empty, raises IndexError.
        rzempty sequence)r
IndexErrorr)rseqrrrr_szStrongRandom.choicecCs:t|}x,tt|D]}||t|||<qWdS)zShuffle the sequence in place.N)listrangerpopr)rxitemsirrrrhszStrongRandom.shufflecCspt|}||krtdg}i}xJt|D]>}d}x|dksD||krP||}q4W|||d||<q*W|S)zNReturn a k-length list of unique elements chosen from the population sequence.zsample larger than populationNr)rrr.rappend)rZ
populationrr%ZretvalZselectedr2r&rrrrrszStrongRandom.sample)NN)
__name__
__module____qualname__rrrrrrrrrrrr#s

"	
)rr
long_to_bytesr )__doc__Z__revision____all__ZCryptor	sysversion_infoZCrypto.Util.py21compatobjectrZ_rrrrrrrZCrypto.Util.numberrrr7r rrrr<module>s`