A True Random Number Generator for python.
Project description
Randomless
A python module which provides a True Random Number Generator (TRNG) based on the electronic noise captured by your webcam. The api is mostly compatible with Python's default random module.
Requirements
Python 3
opencv-python
numpy
A webcam with drivers installed.
Installation
pip install randomless
Usage
Import.
from randomless import Random
Create a Random class instance.
random = Random()
Generate a random number just like you would with Python's default random module.
random.random()
Use any other random method the same way as it is with Python's RNG.
print('randrange:', random.randrange(0, 5, 1))
print('randint:', random.randint(0, 5))
print('choice:', random.choice([1, 2, 3, 4, 5]))
l = [1, 2, 3, 4, 5]
random.shuffle(l)
print('shuffle:', l)
print('sample:', random.sample([1, 2, 3, 4, 5], 3))
print('random:', random.random())
print('uniform:', random.uniform(0, 5))
print('triangular:', random.triangular(0, 1, 0.5))
print('betavariate:', random.betavariate(1, 1))
print('expovariate:', random.expovariate(5))
print('gammavariate:', random.gammavariate(1, 1))
print('gauss:', random.gauss(1, 1))
print('lognormvariate:', random.lognormvariate(1, 1))
print('normalvariate:', random.normalvariate(1, 1))
print('vonmisesvariate:', random.vonmisesvariate(1, 1))
print('paretovariate:', random.paretovariate(1))
print('weibullvariate:', random.weibullvariate(1, 1))
Stop the process of collecting noise from your webcam.
random.release()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
randomless-0.1.8.tar.gz
(3.4 kB
view hashes)
Built Distribution
randomless-0.1.8-py3-none-any.whl
(17.6 kB
view hashes)
Close
Hashes for randomless-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bd4254ecc607f2af39b02fff1bafdd87dc479887d8132ca0be94306868e7697 |
|
MD5 | 4948dd29ed75c0afaaaac44db468b587 |
|
BLAKE2b-256 | 85ae1faf370aa37ca7cdb4842314492d21bd55e35ece4af7c5e4c83b76ed028d |