This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Expo Crypto iconExpo Crypto

A universal library for crypto operations.

Android
iOS
tvOS
Web
Included in Expo Go
Recommended version:
~15.0.9

expo-crypto enables you to hash data in an equivalent manner to the Node.js core crypto API.

Installation

Terminal
- npx expo install expo-crypto
- yarn expo install expo-crypto
- pnpm expo install expo-crypto
- bun expo install expo-crypto

If you are installing this in an existing React Native app, make sure to install expo in your project.

Usage

Basic Crypto usage
import { 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... */ })(); }, []); return ( <View style={styles.container}> <Text>Crypto Module Example</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, });

API

import * as Crypto from 'expo-crypto';

No API data file found, sorry!

Error codes

CodeDescription
ERR_CRYPTO_UNAVAILABLEWeb Only. Access to the WebCrypto API is restricted to secure origins (localhost/https).
ERR_CRYPTO_DIGESTAn invalid encoding type provided.