ethers
6.14.0
DOCUMENTATION
Getting Started
Ethereum Basics
Application Programming Interface
Cookbook
Cookbook: ENS Recipes
React Native
Signing
Migrating from v5
Contributions and Hacking
License and Copyright
Single Page
Documentation »Cookbook »React Native
 React Native

When using React Native, many of the built-in cryptographic primitives can be replaced by native, substantially faster implementations.

This should be available in its own package in the future, but for now this is highly recommended, and requires installing the Quick Crypto package.

import { ethers } from "ethers"; import crypto from "react-native-quick-crypto"; ethers.randomBytes.register((length) => { return new Uint8Array(crypto.randomBytes(length)); }); ethers.computeHmac.register((algo, key, data) => { return crypto.createHmac(algo, key).update(data).digest(); }); ethers.pbkdf2.register((passwd, salt, iter, keylen, algo) => { return crypto.pbkdf2Sync(passwd, salt, iter, keylen, algo); }); ethers.sha256.register((data) => { return crypto.createHash('sha256').update(data).digest(); }); ethers.sha512.register((data) => { return crypto.createHash('sha512').update(data).digest(); });
← Cookbook: ENS Recipes
Signing→
The content of this site is licensed under the Creative Commons License. Generated on September 12, 2023, 7:27am.