$ npm install react-native-crypto-module --save
$ react-native link react-native-crypto-module
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-crypto-module
and addRNCryptoModule.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNCryptoModule.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNCryptoModulePackage;
to the imports at the top of the file - Add
new RNCryptoModulePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-crypto-module' project(':react-native-crypto-module').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-crypto-module/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-crypto-module')
- In Visual Studio add the
RNCryptoModule.sln
innode_modules/react-native-crypto-module/windows/RNCryptoModule.sln
folder to their solution, reference from their app. - Open up your
MainPage.cs
app
- Add
using Crypto.Module.RNCryptoModule;
to the usings at the top of the file - Add
new RNCryptoModulePackage()
to theList<IReactPackage>
returned by thePackages
method
import RNCryptoModule from 'react-native-crypto-module';
// TODO: What to do with the module?
RNCryptoModule;
Most method implementations are borrowed from react-native-rsa-native, with some adjustments for a specific use case.
getKeyStoreIsLoaded
- always returns truegetKeyAliases
- returns list of key aliasescontainsKeyAlias
- indicates whether key alias already existsdeleteKeyEntry
- removes key pairloadKeyStore
- does nothing (not applicable on iOS)unloadKeyStore
- does nothing (not applicable on iOS)sign
- signs a message using a given private keyaddKeyPair
- generate and save a new key pair, returns public key PEMsecureRandom
- generate secure random (Base64 encoded)
getKeyStoreCertificate
- unused, not applicable on iOSkeyStoreSize
- unused, not applicable on iOSverify
- unused, Android implementation is not validgetKeyAsPem
- unused
All methods are implemented asynchronously and return a promise
Clone the repository, then
$ cd CryptoApp
$ react-native install ../CryptoModule # ignore error at the end of installation
$ react-native link react-native-crypto-module