# js-crypto-random

> Universal Module for Secure Random Generator in JavaScript

Latest version **1.0.5** (published 2023-09-27) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-09-27 |
| First published | 2018-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jun Kurihara |
| Maintainers | kurihara |
| Keywords | crypto, random, webcrypto |

## Links

- npm: https://www.npmjs.com/package/js-crypto-random
- Repository: https://github.com/junkurihara/jscu
- Homepage: https://github.com/junkurihara/jscu/tree/master/packages/js-crypto-random#readme
- Issues: https://github.com/junkurihara/jscu/issues
- npm.io page: https://npm.io/package/js-crypto-random

## Dependencies (1)

- [js-crypto-env](https://npm.io/package/js-crypto-env.md) ^1.0.5

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2023-09-27
- 1.0.4 — 2022-02-04
- 1.0.3 — 2021-11-22
- 1.0.2 — 2021-03-13
- 1.0.1 — 2021-03-13
- 1.0.0 — 2020-09-30
- 0.4.3 — 2020-01-14
- 0.4.2 — 2019-12-08
- 0.4.1 — 2019-11-19
- 0.4.0 — 2019-11-19
- 0.3.5 — 2019-07-19
- 0.3.4 — 2019-07-13
- 0.3.3 — 2019-06-16
- 0.3.2 — 2019-06-05
- 0.3.1 — 2019-06-05
- … 16 more at https://npm.io/package/js-crypto-random/versions

## README

Universal Module for Secure Random Generator in JavaScript
--
[![npm version](https://badge.fury.io/js/js-crypto-random.svg)](https://badge.fury.io/js/js-crypto-random)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> **WARNING**: At this time this solution should be considered suitable for research and experimentation, further code and security review is needed before utilization in a production application.

# Introduction and Overview

This library is designed to 'universally' provide functions of random sequence generators, i.e., it works both on most modern browsers and on Node.js just by importing from NPM/source code. Note that in the design principle, the library fully utilizes native APIs like WebCrypto API to accelerate its operation if available.

# Installation

At your project directory, do either one of the following.

- From npm/yarn:
  ```shell
  $ npm install --save js-crypto-random // npm
  $ yarn add js-crypto-random // yarn
  ```
- From GitHub:
  ```shell
  $ git clone https://github.com/junkurihara/jscu.git
  $ cd js-crypto-utils/packages/js-crypto-random
  & yarn build
  ```

Then you should import the package as follows.

```shell
import random from 'js-crypto-random'; // for npm
import random from 'path/to/js-crypto-random/dist/index.js'; // for github
```

The bundled file is also given as `js-crypto-random/dist/jscrandom.bundle.js` for a use case where the module is imported as a `window.jscrandom` object via `script` tags.

# Usage

## Generate random byte sequence

```javascript
// now you get an Uint8Array of 32 bytes filled with randomly generated values
const randomBytes = random.getRandomBytes(32);
```

## Generate random ascii sequence

```javascript
// now you get a string of 32 ASCII characters generated in a cryptographically random manner
const randomAscii = random.getRandomAsciiString(32);
```

# License

Licensed under the MIT license, see `LICENSE` file.

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