# react-native-crypto-aes

> ## Getting started

Latest version **0.1.0** (published 2018-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-crypto-aes
pnpm add react-native-crypto-aes
yarn add react-native-crypto-aes
bun add react-native-crypto-aes
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-09-02 |
| First published | 2018-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nicholas Bertazzon |
| Maintainers | nicholasbertazzon |
| Keywords | react-native |

## Links

- npm: https://www.npmjs.com/package/react-native-crypto-aes
- Repository: https://github.com/github_account/react-native-crypto-aes
- Homepage: https://github.com/github_account/react-native-crypto-aes#readme
- Issues: https://github.com/github_account/react-native-crypto-aes/issues
- npm.io page: https://npm.io/package/react-native-crypto-aes

## Recent versions

- 0.1.0 (latest) — 2018-09-02

## README

# React Native AES
## Currently Android only, since I don't own a Mac. Still no pbkdf2 support.

## Getting started

`$ npm install react-native-crypto-aes --save`

### Mostly automatic installation

`$ react-native link react-native-crypto-aes`

### Manual installation

#### Android

1. Open up `android/app/src/main/java/[...]/MainApplication.java`
  - Add `import it.nicholasbertazzon.crypto.aes.RNCryptoAesPackage;` to the imports at the top of the file
  - Add `new RNCryptoAesPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
  	```
  	include ':react-native-crypto-aes'
  	project(':react-native-crypto-aes').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-crypto-aes/android')
  	```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
  	```
      implementation project(':react-native-crypto-aes')
  	```

## Usage (API)

### **hashKey**(params)
Hash the given key, in order to be used for encrypt and decrypt.
<br/>Returns a base64 hashed key, see the example.

**Params (object):**
- **key (required)**: standard utf-8 text
- **algorithm**: default to SHA-256

### **encrypt**(params)
Encrypt the given text.
<br/>Returns an object with the encrypted text and the initial vector, both encoded in base64, see the example.

**Params (object):**
- **key (required) (base64)**
- **text (required)**: standard utf-8 text
- **algorithm**: default to AES/CBC/PKCS5Padding

### **decrypt**(params)
Decrypt the given encrypted text.
<br/>Returns the decrypted text.

**Params (object):**
- **key (required) (base64)**
- **encrypted (required) (base64)**: the encrypted text
- **iv (required) (base64)**: iv given by the encrypt function
- **algorithm**: default to AES/CBC/PKCS5Padding

### Example
```javascript
import AES from 'react-native-react-native-crypto-aes';

AES.hashKey({
            key: "My key"
        }).then(key => {
            AES.encrypt({
                key: key,
                text: "Text to encrypt"
            }).then(response => {
                AES.decrypt({
                    key: key,
                    iv: response.iv,
                    encrypted: response.encrypted
                }).then(text => alert(text));
            });
        });
```

---
_Source: https://npm.io/package/react-native-crypto-aes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
