Skip to content

Instantly share code, notes, and snippets.

@eugenehp
Created April 5, 2021 20:13
Show Gist options
  • Save eugenehp/b6bbf33e01e4bdc80525bf03e2a9f528 to your computer and use it in GitHub Desktop.
Save eugenehp/b6bbf33e01e4bdc80525bf03e2a9f528 to your computer and use it in GitHub Desktop.
react-native-randomness main wrapper
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