
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
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 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.
The npm package react-native-get-random-values receives a total of 1,030,270 weekly downloads. As such, react-native-get-random-values popularity was classified as popular.
We found that react-native-get-random-values demonstrated a not healthy version release cadence and project activity because the last version was released 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 MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.