JSPM

randombytes-pure

4.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 228
  • Score
    100M100P100Q80873F
  • License ISC

JS-only implementation of randomBytes, intended for use with React Native and other limited runtimes

Package Exports

  • randombytes-pure

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (randombytes-pure) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Validate code on push

RandomBytes-Pure

Motivation

This is a fork of react-native-randombytes, and is a superset of its exposed randomBytes API. You probably want to use that library if you're comfortable/capable of using react-native link. If, however, you're using the Expo "Managed Workflow" or otherwise don't want to mess around with native dependencies, then this library is the one for you.

Implementation Overview

This library uses the SJCL pseudo-random generator. That library is small, fast, and memory-efficient.

Usage

import randomBytes from "randombytes-pure";

const rand = randomBytes(4);

That is it. Now rand is a Buffer with 4 pseudo-random bytes. Enjoy.

Installation

yarn add randombytes-pure

If you want to use this module anywhere you might otherwise use react-native-randombytes, AND you are using yarn or some other build tool that supports "resolutions" in package.json, then just add this to your package.json:

"resolutions": {
    "react-native-randombytes": "randombytes-pure"
}

Versioning

This library follows semver using Semantic Release and Conventional Commits.