Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-crypto-random

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-crypto-random

Universal Module for Secure Random Generator in JavaScript

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65K
increased by6.31%
Maintainers
1
Weekly downloads
 
Created
Source

Universal Module for Secure Random Generator in JavaScript

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 be 'universal' as a random sequence generator, i.e., it works both on most 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/js-crypto-random.git
    

Then you should import the package as follows.

import random from 'js-crypto-random'; // for npm
import random from 'js-crypto-random/dist/index.js'; // for github

Usage

Generate random byte sequence

random.getRandomBytes(32).then( (rb) => {
  // now you get an Uint8Array of 32 bytes filled with randomly generated values
});

Generate random ascii sequence

random.getRandomAsciiString(32)( (ra) => {
  // now you get a string of 32 ASCII characters generated in a cryptographically random manner
});

License

Licensed under the MIT license, see LICENSE file.

Keywords

FAQs

Package last updated on 26 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc