as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
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.1",
         "@amazon-devices/keplerscript-turbomodule-api": "~1.0.0",
         ...
     }
    
  2. Reinstall dependencies using the 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

See the dedicated documentation page for information about this library and API reference: Official Expo documentation for expo-crypto.

Methods

Method Description Supported
digest Get a hash from a passed array buffer (or array buffer view) ✅ Yes
digestStringAsync Get a hash from a passed string ✅ Yes
getRandomBytes Get an array buffer filled with random values ✅ Yes
getRandomBytesAsync Get an array buffer filled with random values ✅ Yes
getRandomValues Fill an array buffer with random values ✅ Yes
randomUUID Generate a random UUID ✅ Yes
CryptoDigestAlgorithm Enum for the Expo Crypto library. ✅ Yes
MD2 The one unsupported method from the CryptoDigestAlgorithm library. ❌ No

Supported versions

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

Supported Third-Party Libraries and Services.


Last updated: Sep 30, 2025