# react-native-des-cbc

> A des crypto for react-native

Latest version **1.0.9** (published 2020-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-des-cbc
pnpm add react-native-des-cbc
yarn add react-native-des-cbc
bun add react-native-des-cbc
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2020-02-26 |
| First published | 2017-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 89 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | YunJiang.Fang & PizzaLiu |
| Maintainers | pizzaliu |
| Keywords | react-native, react-component, ios, android, des, crypto, remobile, mobile, pizzaliu |

## Links

- npm: https://www.npmjs.com/package/react-native-des-cbc
- Repository: https://github.com/PizzaLiu/react-native-des
- Issues: https://github.com/PizzaLiu/react-native-des/issues
- npm.io page: https://npm.io/package/react-native-des-cbc

## Alternatives

- [adhdev](https://npm.io/package/adhdev.md) — 11.1K weekly downloads
- [react-slide-button](https://npm.io/package/react-slide-button.md) — 310 weekly downloads
- [better](https://npm.io/package/better.md) — 42 weekly downloads
- [react-native-swipe-image](https://npm.io/package/react-native-swipe-image.md) — 22 weekly downloads
- [nl.fokkezb.pulltorefresh](https://npm.io/package/nl.fokkezb.pulltorefresh.md) — 11 weekly downloads

## Recent versions

- 1.0.9 (latest) — 2020-02-26
- 1.0.8 — 2020-02-24
- 1.0.7 — 2018-11-05
- 1.0.6 — 2017-03-15
- 1.0.5 — 2017-03-15
- 1.0.4 — 2017-03-15

## README

# React Native Des (remobile)
A des crypto for react-native

> fork from remobile/react-native-des
> only add cbc feature in Android and iOS

## Installation
```sh
npm install react-native-des-cbc --save
```

### Installation (iOS)
1. Drag `node_modules/react-native-des-cbc/ios/RCTDes.xcodeproj` to your project's `Libraries` in Xcode.
2. Click on your main project and select `Build Phases` then drag `libRCTDes.a` from the `Libraries/RCTDes.xcodeproj/Products` into `Link Binary With Libraries`.
3. (Optional) Look for `Build Settings/Header Search Paths` and make sure it contains both `$(SRCROOT)/../../../react-native/React` as recursive.
4. `command + b` to buil it.

### Installation (Android)

1/3. In `android/settings.gradle`

```gradle
//...
include ':react-native-des-cbc'
project(':react-native-des-cbc').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-des-cbc/android')
```

2/3. In `android/app/build.gradle`

```gradle
//...
dependencies {
    //...
    compile project(':react-native-des-cbc')
}
```

3/3. register module (in `MainApplication.java`)

```java
//......
import com.remobile.des.RCTDesPackage;  // <--- import
//......

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
          //......
          new RCTDesPackage(),            // <------ add here
         //......
      );
}
```

## Usage

### Example
```js
var Des = require('react-native-des-cbc');

Des.encrypt("fangyunjiang is a good developer", "ABCDEFGH", function(base64) {
    console.log(base64); //wWcr2BJdyldTHn4z3AxA0qBIdHQkIKmpqhTgNuRd3fAFXzvIO5347g==
    Des.decrypt(base64, "ABCDEFGH", function(text) {
        console.log(text); //fangyunjiang is a good developer
    }, function(){
        console.log("error");
    });
}, function() {
    console.log("error");
});

var vec = "cute";
Des.encryptCbc("PizzaLiu is a good developer too", "ABCDEFGH", vec, function(base64) {
    console.log(base64);
    Des.decryptCbc(base64, "ABCDEFGH", vec, function(text) {
        console.log(text); //PizzaLiu is a good developer
    }, function(){
        console.log("error");
    });
}, function() {
    console.log("error");
});
```

### method
- `encrypt(text, key, callback)`
- `encrypt(base64, key, callback)`

- `encryptCbc(text, key, vec, callback)`
- `encryptCbc(base64, key, vec, callback)`


## Server Side
* see https://github.com/remobile/react-native-des/blob/master/server
* support java, nodejs, js, php

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