https://github.com/skepticalhippo/crypto-random
A cryptographically strong random number generator. Designed to be a drop-in replacement for Math.random. Can be used with Node or in a browser.
https://github.com/skepticalhippo/crypto-random
browser crypto javascript nodejs random random-generation random-number-generators
Last synced: 7 months ago
JSON representation
A cryptographically strong random number generator. Designed to be a drop-in replacement for Math.random. Can be used with Node or in a browser.
- Host: GitHub
- URL: https://github.com/skepticalhippo/crypto-random
- Owner: SkepticalHippo
- License: mit
- Created: 2017-04-16T17:08:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-04-11T22:41:49.000Z (9 months ago)
- Last Synced: 2025-06-22T19:08:37.637Z (7 months ago)
- Topics: browser, crypto, javascript, nodejs, random, random-generation, random-number-generators
- Language: JavaScript
- Size: 10.2 MB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Crypto-Random

A zero dependency, cryptographically strong, random number generator.
Designed to be a drop-in replacement for `Math.random`. Can be used with Node or in the browser.
## Supported Versions
* Node 14.x+ (up to Node 18.x)
* For supported browsers please refer to [this MDN article](https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues).
## Install
`npm i crypto-random`
## Usage
```js
const Random = require('crypto-random');
console.log(Random.value()); // a random float between 0 and 1. Replacement function for Math.random.
console.log(Random.range(10, 101)); // a random integer between 10 and 101.
```
## Contributing
Feedback and any contributions are very welcome. Please open up an Issue or a Pull Request.