Skip to content

An npm module for generating random bytes without relying on any native libraries.

License

Notifications You must be signed in to change notification settings

RobertFischer/randombytes-pure

 
 

Repository files navigation

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

yarn add randombytes-pure

npm

npm install --save randombytes-pure

Overriding Dependencies

If you want to use this package in place of react-native-randombytes, and you are using yarn (or something else that supports the "resolutions" field), then you can do this:

{
	"resolutions": {
		"react-native-randombytes": "github:RobertFischer/randombytes-pure#v4.1.0"
	}
}

Versioning

This library follows semver using Semantic Release and Conventional Commits.

About

An npm module for generating random bytes without relying on any native libraries.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages

  • TypeScript 69.4%
  • JavaScript 30.6%