https://github.com/angeal185/random-bytes-js
pseudo random bytes in javascript for the browser
https://github.com/angeal185/random-bytes-js
browser javascript prng pseudo-random pseudo-random-generator random random-bytes
Last synced: 4 months ago
JSON representation
pseudo random bytes in javascript for the browser
- Host: GitHub
- URL: https://github.com/angeal185/random-bytes-js
- Owner: angeal185
- License: mit
- Created: 2019-05-11T03:31:39.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-11T07:13:51.000Z (about 6 years ago)
- Last Synced: 2024-10-16T05:32:27.728Z (9 months ago)
- Topics: browser, javascript, prng, pseudo-random, pseudo-random-generator, random, random-bytes
- Language: JavaScript
- Homepage: https://angeal185.github.io/random-bytes-js
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# random-bytes-js
pseudo random bytes in javascript for the browserdemo: https://angeal185.github.io/random-bytes-js
### Installation
npm
```sh
$ npm install random-bytes-js --save
```bower
```sh
$ bower install random-bytes-js
```git
```sh
$ git clone [email protected]:angeal185/random-bytes-js.git
```#### browser
```html
```
#### nodejs
```js
const rbjs = require('random-bytes-js')
```#### API
```js
/**
* @param {integer} int ~ bytes length
* @param {function} cb ~ optional callback function(err,res)
**/// random bytes as string
rbjs.rand(int, cb)// random bytes as Uint8 array
rbjs.randUint8(int, cb)// random bytes as numbered array
rbjs.randArr(int, cb)// random bytes as numbered string
rbjs.randNumStr(int, cb)// random bytes to hex
rbjs.randHex(int, cb)// random bytes to base64
rbjs.rand64(int, cb)//demo
let sync;
sync = rbjs.rand(10);
console.log(sync)rbjs.rand(10, function(err, res){
if(err){return console.log(err)}
console.log(res)
})sync = rbjs.randUint8(10);
console.log(sync)rbjs.randUint8(10, function(err, res){
if(err){return console.log(err)}
console.log(res)
})sync = rbjs.randArr(10);
console.log(sync)rbjs.randArr(10, function(err, res){
if(err){return console.log(err)}
console.log(res)
})sync = rbjs.randNumStr(10);
console.log(sync)rbjs.randNumStr(10, function(err, res){
if(err){return console.log(err)}
console.log(res)
})sync = rbjs.randHex(10);
console.log(sync)rbjs.randHex(10, function(err, res){
if(err){return console.log(err)}
console.log(res)
})sync = rbjs.rand64(10);
console.log(sync)rbjs.rand64(10, function(err, res){
if(err){return console.log(err)}
console.log(res)
})```