1.0.5 • Published 1 year ago

js-crypto-random v1.0.5

Weekly downloads
4,464
License
MIT
Repository
github
Last release
1 year ago

Universal Module for Secure Random Generator in JavaScript

npm version License: 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:
    $ npm install --save js-crypto-random // npm
    $ yarn add js-crypto-random // yarn
  • From GitHub:
    $ 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.

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

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

Generate random ascii sequence

// 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.

1.0.5

1 year ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

6 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago