LinusU/react-native-get-random-values
关于
为 React Native 实现的轻量版 `getRandomValues`。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文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 anInt8Array, aUint8Array, anInt16Array, aUint16Array, anInt32Array, or aUint32Array. All elements in the array are going to be overridden with random numbers.
Returns the typed array that was passed in.
探索相关项目
加载中…