# crypto-random-int

> get a cryptographically random integer within a range

Latest version **1.0.1** (published 2017-11-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install crypto-random-int
pnpm add crypto-random-int
yarn add crypto-random-int
bun add crypto-random-int
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-11-27 |
| First published | 2017-11-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | continuous-electronics |
| Maintainers | continuous-electronics |
| Keywords | crypto, random, integer, int, cryptographic, cryptographically, cryptography, safe |

## Links

- npm: https://www.npmjs.com/package/crypto-random-int
- Repository: https://github.com/continuousElectronics/crypto-random-int
- Homepage: https://github.com/continuousElectronics/crypto-random-int#readme
- Issues: https://github.com/continuousElectronics/crypto-random-int/issues
- npm.io page: https://npm.io/package/crypto-random-int

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2017-11-27
- 1.0.0 — 2017-11-27

## README

## Crypto-Random-Int

This module produces a function that returns a promise to find a cryptographically safe random integer within in the range and including the two integer arguments. The difference between the two integers must be less than 2<sup>32</sup>. It works in Node JS or a browser.

## Install
```
npm install crypto-random-int 
```

## Usage in Node

```javascript
const cryptoRandomInt = require("crypto-random-int");

cryptoRandomInt(-7, 28)
    .then((randomInt) => { 
        console.log(randomInt); 
    })
    .catch((err) => {
        console.log(err); 
    });
```

## Usage in browser

Download the repository and reference the crypto-random-int.js file as shown below. cryptoRandomInt is placed on the window object and can be referenced globally.
```html
<script src="path/to/crypto-random-int.js"></script>
<script>

let promises = Array(7).fill().map(x => cryptoRandomInt(9, 0));

Promise.all(promises)
    .then((arr) => {
        console.log(arr);
    })
    .catch((err) => {
        console.log(err);
    });

</script>
```

---
_Source: https://npm.io/package/crypto-random-int · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
