1 | var random
|
2 | try {
|
3 | random = require('expo-random')
|
4 | } catch (e) {
|
5 | throw new Error(
|
6 | 'React-Native does not have a built-in secure random generator. ' +
|
7 | 'Install `expo-random` locally or ' +
|
8 | 'if you don’t need unpredictable IDs, you can use `nanoid/non-secure`.'
|
9 | )
|
10 | }
|
11 |
|
12 | module.exports = function (bytes) {
|
13 | return random.getRandomBytesAsync(bytes)
|
14 | }
|