https://github.com/0xf0xx0/qranode
Node wrapper for https://quantumnumbers.anu.edu.au
https://github.com/0xf0xx0/qranode
nodejs qrng quantum-randomness
Last synced: 10 months ago
JSON representation
Node wrapper for https://quantumnumbers.anu.edu.au
- Host: GitHub
- URL: https://github.com/0xf0xx0/qranode
- Owner: 0xf0xx0
- License: gpl-3.0
- Created: 2020-07-28T22:47:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-12-17T15:07:41.000Z (over 1 year ago)
- Last Synced: 2025-08-09T13:51:29.910Z (11 months ago)
- Topics: nodejs, qrng, quantum-randomness
- Language: JavaScript
- Homepage:
- Size: 57.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# QRANode
## A wrapper for ANUs Quantum RNG API.
See here for more info on the rng: https://quantumnumbers.anu.edu.au/
you should donate to them too, this is really cool :3
[NPM Link](https://npmjs.com/package/qranode)
## Installation
`npm i qranode`
## Usage:
```js
const qranode = require('qranode')
/// get the request function
const qrng = qranode('API_KEY_GOES_HERE', 'optional HTTP user agent string')
/// get random uint8 (default values)
const uint8Arr = await qrng() // -> { success: true, type: 'uint8', length: '1', data: [ 126 ] }
// .then.catch
qrng({ dataType: 'uint8', amount: 5 }) // get 5 numbers from 0 to 255
.then(console.log) // log the output
.catch(console.error) // or the errors, if any
// you can even get hex!
qrng({ dataType: 'hex16', amount: 5, blockSize: 2 }) // get 5 hex strings, each string consisting of 2 hex blocks between 0000 and ffff
```
The API returns a JSON object with the success status, the type requested, the length of the array, and the array of numbers. The example below is the result of a request for two hex16 numbers with a block size of 4.
```js
{
success: true,
type: 'hex16',
length: '2',
data: [ '2f2497d207a39d67', 'dd537fa2b1c4c6b2' ]
}
```