https://github.com/nazar-pc/random-bytes-numbers
Generate random bytes and numbers in Node.js and modern browsers with security in mind
https://github.com/nazar-pc/random-bytes-numbers
Last synced: 4 months ago
JSON representation
Generate random bytes and numbers in Node.js and modern browsers with security in mind
- Host: GitHub
- URL: https://github.com/nazar-pc/random-bytes-numbers
- Owner: nazar-pc
- Created: 2018-05-05T04:20:57.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-16T01:03:04.000Z (about 7 years ago)
- Last Synced: 2025-03-15T15:18:07.198Z (4 months ago)
- Language: LiveScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Random bytes and numbers [](https://travis-ci.org/nazar-pc/random-bytes-numbers)
Generate random bytes and numbers in Node.js and modern browsers with security in mind.This small set of functions takes security serious and applies workarounds for JavaScript-specific quirks.
## How to install
```
npm install random-bytes-numbers
```## How to use
Node.js:
```javascript
var random_bytes_numbers = require('random-bytes-numbers')// Do stuff
```
Browser:
```javascript
requirejs(['random-bytes-numbers'], function (random_bytes_numbers) {
// Do stuff
})
```## API
### random_bytes_numbers.random_bytes(size : number) : Uint8Array
Generate random bytes of specified size.### random_bytes_numbers.random_int(min : number, max : number) : number
Generate random integer from range `[min, max]`.
`max - min` should be less or equal than `Number.MAX_SAFE_INTEGER`, which is 53bits.### random_bytes_numbers.random() : number
Replacement for `Math.random()` that can be used for cryptographic operations, returns number from range `[0, 1)`.## Contribution
Feel free to create issues and send pull requests (for big changes create an issue first and link it from the PR), they are highly appreciated!When reading LiveScript code make sure to configure 1 tab to be 4 spaces (GitHub uses 8 by default), otherwise code might be hard to read.
## License
Free Public License 1.0.0 / Zero Clause BSD Licensehttps://opensource.org/licenses/FPL-1.0.0
https://tldrlegal.com/license/bsd-0-clause-license