# secure-random-number

> Create random floats, securely and with lots of entropy

Latest version **1.0.0** (published 2023-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install secure-random-number
pnpm add secure-random-number
yarn add secure-random-number
bun add secure-random-number
```

## 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.0 |
| Published | 2023-10-14 |
| First published | 2023-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aritz Beobide-Cardinal |
| Maintainers | aritz-cracker |

## Links

- npm: https://www.npmjs.com/package/secure-random-number
- Repository: https://github.com/ARitz-Cracker/secure-random-number
- Issues: https://github.com/ARitz-Cracker/secure-random-number/issues
- npm.io page: https://npm.io/package/secure-random-number

## Recent versions

- 1.0.0 (latest) — 2023-10-14

## README

# secure-random-number

Math.random, but slightly more unpredictable!

## What?

Math.random isn't actually random, and is, in-fact, very predictable. This library uses NodeJS's built-in `crypto` module or `crypto.getRandomValues()` on web browsers for "unpredictable" randomness.

## Yeah, but something like this already exists, right?

Right, _however_ they tend to create a random uint32, then divide it by 2 \*\* 32. Which means only (2 \*\* 32 - 1) possible values, at a range from 0 to 0.9999999997671694. Which is GROSS, and DISGUSTING. This library works by filling a 64-bit float's entire 52-bit mantissa with random values! Which allows for 2 \*\* 52 (ish) possible values, at a range from 0 to 0.9999999999999998! Which, while not perfect, is a whole lot better.

Note: I made this package years ago but never published it for some reason.

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