as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

expo-crypto

@amazon-devices/expo-crypto is a universal library for crypto operations that enables you to hash data in an equivalent manner to the Node.js core crypto API.

Installation

  1. Add the JavaScript library dependency in the package.json file.

    Copied to clipboard.

     dependencies: {
         ...
         "@amazon-devices/expo-crypto": "~2.0.0",
         "@amazon-devices/keplerscript-turbomodule-api": "~1.0.0",
         ...
     }
    
  2. Reinstall dependencies using npm install command.

Examples

Copied to clipboard.

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

export const App = () => {
  const [digest, setDigest] = useState<string>();

  useEffect(() => {
    (async () => {
      const digestStr = await Crypto.digestStringAsync(
        Crypto.CryptoDigestAlgorithm.SHA256,
        'GitHub stars are neat 🌟',
      );
      setDigest(digestStr);
    })();
  }, []);

  return (
    <View style={styles.container}>
      <Text style={styles.text}>Crypto Module Example {digest}</Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'white',
    justifyContent: 'center',
    alignItems: 'center',
  },
  text: {
    fontSize: 30,
    color: 'black',
  },
});

API reference

Check out the dedicated documentation page for info about this library, API reference and more: Official Expo documentation for expo-crypto.

Methods

Method Description
digest Get hash from passed array buffer (or array buffer view)
digestStringAsync Get hash from passed string
getRandomBytes Get array buffer filled with random values
getRandomBytesAsync Get array buffer filled with random values
getRandomValues Fill an array buffer with random values
randomUUID Generate random UUID.

Implementation details

Vega supports all cryptographic hash functions (CryptoDigestAlgorithm enum) except for MD2.

Supported versions

Package Version Based On @amazon-devices/react-native-kepler version
2.0.x 12.7.0 2.0.x

Additional resources

For information on additional libraries, see Supported Third-Party Libraries and Services.


Last updated: Sep 30, 2025