statlab / cryptorandom Goto Github PK
View Code? Open in Web Editor NEWPseudorandom number generators based on cryptographic hash functions
Home Page: https://statlab.github.io/cryptorandom/
License: BSD 2-Clause "Simplified" License
Pseudorandom number generators based on cryptographic hash functions
Home Page: https://statlab.github.io/cryptorandom/
License: BSD 2-Clause "Simplified" License
Random integers in [a, b] should be computed by taking ceil(log_2(b-a)) random bits, discarding values that are bigger than (b-a), then adding a to retained values.
the current code will fail if k > HASHLEN.
many calls to nextRandom() could be saved in repeated calls to getrandbits when k<<256 by having a class variable to cache "leftover" bits rather than discarding (HASHLEN-k). Track the number of bits remaining, and call nextRandom() when the cache of bits is exhausted.
When you create a new SHA256 object using the constructor without parameters
sha256 = SHA256()
,
the following functions will return AttributeErrors
sha256.jumpahead() --> AttributeError: 'NoneType' object has no attribute 'update'
sha256.next() --> 'AttributeError: NoneType' object has no attribute 'update'
sha256.random() --> AttributeError: 'NoneType' object has no attribute 'digest'
sha256.randint_trunc() --> AttributeError: 'NoneType' object has no attribute 'digest'
-- (Depricated)
sha256.getrandbits() --> AttributeError: 'NoneType' object has no attribute 'digest'
sha256.randbelow_from_randbits() --> AttributeError: 'NoneType' object has no attribute 'digest'
sha256.randint() --> AttributeError: 'NoneType' object has no attribute 'digest'
r = SHA256(1)
r.randbelow_from_randbits(-1)
r = SHA256(1)
r.randbelow_from_randbits(-1)
Both of these function calls cause kernel errors in jupyterhub, and unlike in the docstring for randbelow_from_randbits, no ValueError is raised if n==0.
I suggest assert n > 0
is added
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.