Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
react-native-get-random-values
Advanced tools
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.
The react-native-get-random-values package is a polyfill for the Web Crypto API's getRandomValues method, which allows you to generate cryptographically strong random values in a React Native environment.
Generate Random Values
This feature allows you to generate cryptographically strong random values. The code sample demonstrates how to use the getRandomValues method to fill a typed array with random values.
const { getRandomValues } = require('react-native-get-random-values');
const array = new Uint32Array(10);
getRandomValues(array);
console.log(array);
The react-native-crypto package provides a full implementation of the Node.js crypto module for React Native. It includes functionalities for cryptographic operations such as hashing, encryption, and random value generation. Compared to react-native-get-random-values, it offers a broader range of cryptographic features.
The react-native-securerandom package is designed to generate secure random numbers in a React Native environment. It is similar to react-native-get-random-values in that it focuses on generating cryptographically secure random values, but it does not polyfill the Web Crypto API.
crypto.getRandomValues
for React NativeA small implementation of crypto.getRandomValues
for React Native. This is useful to polyfill for libraries like uuid that depend on it.
npm install --save 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.
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())
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.
FAQs
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.
We found that react-native-get-random-values demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.