react-native-get-random-values
A small implementation of `crypto.getRandomValues` for React Native. This is useful to polyfill for libraries like [uuid](https://www.npmjs.com/package/uuid) that depend on it.
Last updated 4 years ago by linusu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install react-native-get-random-values 
SYNC missed versions from official npm registry.

crypto.getRandomValues for React Native

A small implementation of crypto.getRandomValues for React Native. This is useful to polyfill for libraries like uuid that depend on it.

Installation

npm install react-native-get-random-values
npx pod-install

???? If you use the Expo managed workflow you will see "CocoaPods is not supported in this project" - this is fine, it's not necessary.

Usage

This library works as a polyfill for the global crypto.getRandomValues.

// Add this line to your `index.js`
import 'react-native-get-random-values'

Now you can use uuid or other libraries that assume crypto.getRandomValues is available.

import { v4 as uuid } from 'uuid'

console.log(uuid())

API

crypto.getRandomValues(typedArray)

The crypto.getRandomValues() method lets you get cryptographically strong random values. The array given as the parameter is filled with random numbers (random in its cryptographic meaning).

To guarantee enough performance, implementations are not using a truly random number generator, but they are using a pseudo-random number generator seeded with a value with enough entropy. The PRNG used differs from one implementation to the other but is suitable for cryptographic usages. Implementations are also required to use a seed with enough entropy, like a system-level entropy source.

  • typedArray - Is an integer-based TypedArray, that is an Int8Array, a Uint8Array, an Int16Array, a Uint16Array, an Int32Array, or a Uint32Array. All elements in the array are going to be overridden with random numbers.

Returns the typed array that was passed in.

Current Tags

  • 1.8.0                                ...           latest (4 years ago)

14 Versions

  • 1.8.0                                ...           4 years ago
  • 1.7.2                                ...           4 years ago
  • 1.7.1                                ...           4 years ago
  • 1.7.0                                ...           5 years ago
  • 1.6.0                                ...           5 years ago
  • 1.5.1                                ...           5 years ago
  • 1.5.0                                ...           6 years ago
  • 1.4.0                                ...           6 years ago
  • 1.3.1                                ...           6 years ago
  • 1.3.0 [deprecated]           ...           6 years ago
  • 1.2.0 [deprecated]           ...           6 years ago
  • 1.1.0 [deprecated]           ...           8 years ago
  • 1.0.1 [deprecated]           ...           8 years ago
  • 1.0.0 [deprecated]           ...           8 years ago
Maintainers (1)
Downloads
Today 1
This Week 7
This Month 7
Last Day 1
Last Week 13
Last Month 14
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |