https://github.com/reime005/react-native-secure-element
The most secure way to encrypt and decrypt personal data on a mobile device. Automatically E2E tested and deployed via Github Actions CI/CD.
https://github.com/reime005/react-native-secure-element
android hacktoberfest ios java keychain keystore objc react react-native security typescript
Last synced: 10 months ago
JSON representation
The most secure way to encrypt and decrypt personal data on a mobile device. Automatically E2E tested and deployed via Github Actions CI/CD.
- Host: GitHub
- URL: https://github.com/reime005/react-native-secure-element
- Owner: reime005
- License: mit
- Created: 2019-12-22T15:22:15.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-26T14:48:25.000Z (about 3 years ago)
- Last Synced: 2025-03-18T13:14:39.658Z (11 months ago)
- Topics: android, hacktoberfest, ios, java, keychain, keystore, objc, react, react-native, security, typescript
- Language: Java
- Homepage:
- Size: 1.77 MB
- Stars: 33
- Watchers: 3
- Forks: 3
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
Secure Element for React Native
React Native Secure Element provides functionality to use on-device and hardware-based secure encryption and decryption.
Both native modules are also usable without React Native via gradle and cocoa pods. Thus, they also benefit from being tested by E2E tests.
The Android side uses the `android.security.keystore` API and requires a minimum SDK version of 23, due to availability of the hardware-backed security.
The iOS side uses the CommonCrypto and LocalAuthentication APIs. It saves the key pairs in the keychain or secure enclave if available.
[](http://npm.im/react-native-secure-element)



See examples in [src/examples](./src/examples).
```javascript
// React Hooks example
import { useSecureElement } from 'react-native-secure-element';
const Example = () => {
const { encrypt } = useSecureElement();
const [encryptedBase64Text, setEncryptedBase64Text] = useState('');
useEffect(
async () => {
try {
const val = await encrypt('someKey', 'toEncrypt');
setEncryptedBase64Text(val);
} catch (e) {
console.warn(e);
setEncryptedBase64Text(e.message);
}
},
[]
)
{encryptedBase64Text}
}
```
## Automated E2E (UI) Tests Preview
With Github Actions, each commit automatically triggers a full build cycle. This includes running End-to-End (E2E) or UI tests on an iOS Simulator and Android Emulator. This has the benefit of having only tested and not _breaking code_ merged into the *master* branch.

## Features
- Full TypeScript support
- Automatically deployed and tested (CI/CD) via Github Actions
- Extremely secure iOS encryption and decryption via secure enclave, keychain and elliptic curves. No third party dependencies
- Very secure Android encryption and decryption via Android KeyStore
- Natively (without React Native) available implementation
## Why / Purpose
The purpose of this repository is to provide a secure way to decrypt and encrypt values. Such values could consist of sensitive user data or authentication secrets (TOTP, ...).
## API
See types definition in [src/typescript](./src/typescript/index.d.ts).
## Installation
To install react-native-secure-element, do either
```bash
npm install --save react-native-secure-element
```
or
```bash
yarn add react-native-secure-element
```
Note that this requires a react-native version of at least 0.60.0, to use its auto linking feature.
### Native Android Dependency
Via gradle/maven dependency:
```groovy
implementation 'com.android.secureelement:android:+'
```
### Native iOS Dependency
Via cocoapods dependency:
```ruby
pod 'SecureElement'
```
---
## TODO
Sorted by priority (higher = higher).
* User authentication functionality (without encryption)
* Signing certificates
* React Hooks
* Error handling/formatting