Created
April 5, 2021 20:13
-
-
Save eugenehp/b6bbf33e01e4bdc80525bf03e2a9f528 to your computer and use it in GitHub Desktop.
react-native-randomness main wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NativeModules } from 'react-native'; | |
import { decodeAsBytes } from './base64'; | |
const { Randomness } = NativeModules; | |
export const random = async (length: number = 16): Promise<Uint8Array> => { | |
const base64: string = await Randomness.random(length); | |
const data = decodeAsBytes(base64); | |
return data; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment