It failed because the native React runtime does not include the Node standard library

Viewed 1441
1 Answers

for expo instead of crypto you can use expo-crypto you can install it as below expo install expo-crypto

in your codes

import React, { useEffect } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import * as Crypto from 'expo-crypto';

export default function App() {
  useEffect(() => {
    (async () => {
      const digest = await Crypto.digestStringAsync(
        Crypto.CryptoDigestAlgorithm.SHA256,
        'Github stars are neat'
      );
      console.log('Digest: ', digest);
      /* Some crypto operation... */
    })();
  }, []);
...

as from exp documentation

Related