Skip to content

Commit fd2dce3

Browse files
authored
Merge pull request #1 from LamNguyen17/update_readme
update readme
2 parents 413b060 + 3956abf commit fd2dce3

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

README.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# react-native-crypto-algorithm
22

3-
[![](https://img.shields.io/badge/yarn-v1.0.0-blue)](https://www.npmjs.com/package/react-native-encryption-algorithm)
3+
[![](https://img.shields.io/badge/yarn-v1.0.1-blue)](https://www.npmjs.com/package/react-native-encryption-algorithm)
44
[![](https://img.shields.io/badge/native_language-Kotlin_&_Swift-green)](https://www.npmjs.com/package/react-native-encryption-algorithm)
55
[![](https://img.shields.io/badge/size-72.7_kB-red)](https://www.npmjs.com/package/react-native-encryption-algorithm)
66
[![](https://img.shields.io/badge/license-MIT-8A2BE2)](https://github.com/LamNguyen17/react-native-encryption-algorithm/blob/master/LICENSE)
77
[![](https://img.shields.io/badge/author-Forest_Nguyen-f59642)](https://github.com/LamNguyen17)
88

99
## Installation
1010
```sh
11-
npm install react-native-encryption-algorithm
11+
npm install react-native-crypto-algorithm
1212
```
1313
or
1414
```sh
15-
yarn add react-native-encryption-algorithm
15+
yarn add react-native-crypto-algorithm
1616
```
1717

1818
### Installation (iOS)
@@ -26,7 +26,7 @@ pod install
2626

2727
##### Using React Native Link (React Native 0.59 and lower)
2828

29-
Run `react-native link react-native-encryption-algorithm` after which you should be able to use this library on iOS.
29+
Run `react-native link react-native-crypto-algorithm` after which you should be able to use this library on iOS.
3030

3131
### Installation (Android)
3232

@@ -40,8 +40,8 @@ Run `react-native link react-native-encryption-algorithm` after which you should
4040

4141
```gradle
4242
...
43-
include ':react-native-encryption-algorithm'
44-
project(':react-native-encryption-algorithm').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-encryption-algorithm/android')
43+
include ':react-native-crypto-algorithm'
44+
project(':react-native-crypto-algorithm').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-crypto-algorithm/android')
4545
```
4646

4747
- In `android/app/build.gradle`
@@ -50,19 +50,19 @@ project(':react-native-encryption-algorithm').projectDir = new File(rootProject.
5050
...
5151
dependencies {
5252
...
53-
compile project(':react-native-encryption-algorithm')
53+
compile project(':react-native-crypto-algorithm')
5454
}
5555
```
5656
- register module (in MainApplication.kt)
5757

5858
```kt
5959
......
60-
import com.encryptionalgorithm.EncryptionAlgorithmPackage;
60+
import com.cryptoalgorithm.CryptoAlgorithmPackage;
6161
......
6262

6363
override fun getPackages(): List<ReactPackage> =
6464
PackageList(this).packages.apply {
65-
add(EncryptionAlgorithmPackage());
65+
add(CryptoAlgorithmPackage());
6666
}
6767
```
6868

@@ -75,39 +75,39 @@ override fun getPackages(): List<ReactPackage> =
7575
- 🍁 `encryptAES(value: string, secretKey: string, ivKey?: string)`
7676
- 🍁 `decryptAES(value: string, secretKey: string, ivKey?: string)`
7777
```js
78-
import Encryption from 'react-native-encryption-algorithm';
78+
import Crypto from 'react-native-crypto-algorithm';
7979

8080
// Encrypt
81-
let encryptData = await Encryption.encryptAES('my message', 'my private key', 'my iv key(optional maximum 16 characters)');
81+
let encryptData = await Crypto.encryptAES('my message', 'my private key', 'my iv key(optional maximum 16 characters)');
8282

8383
// Decrypt
84-
let decryptData = await Encryption.decryptAES(encryptData, 'my private key', 'my iv key(optional maximum 16 characters)');
84+
let decryptData = await Crypto.decryptAES(encryptData, 'my private key', 'my iv key(optional maximum 16 characters)');
8585
```
8686

8787
#### 🚀 SHA256
8888
- 🍁 `hashSHA256(value: string)`
8989
```js
90-
import Encryption from 'react-native-encryption-algorithm';
90+
import Crypto from 'react-native-crypto-algorithm';
9191

9292
// Hash SHA256
93-
let hashData = await Encryption.hashSHA256('my hash data');
93+
let hashData = await Crypto.hashSHA256('my hash data');
9494
```
9595

9696
#### 🚀 RSA
9797
- 🍁 `genRSAKeyPair()`
9898
- 🍁 `encryptRSA(value: string, publicKey: string)`
9999
- 🍁 `decryptRSA(value: string, privateKey: string)`
100100
```js
101-
import Encryption from 'react-native-encryption-algorithm';
101+
import Crypto from 'react-native-crypto-algorithm';
102102

103103
// Generate RSA Key Pair
104-
let keyPair = await Encryption.genRSAKeyPair();
104+
let keyPair = await Crypto.genRSAKeyPair();
105105

106106
// Encrypt RSA
107-
let encryptData = await Encryption.encryptRSA('my message', keyPair.publicKey);
107+
let encryptData = await Crypto.encryptRSA('my message', keyPair.publicKey);
108108

109109
// Decrypt RSA
110-
let decryptData = await Encryption.decryptRSA(encryptData, keyPair.privateKey);
110+
let decryptData = await Crypto.decryptRSA(encryptData, keyPair.privateKey);
111111
```
112112

113113
#### 🚀 HMAC / HMAC_AES
@@ -116,19 +116,19 @@ let decryptData = await Encryption.decryptRSA(encryptData, keyPair.privateKey);
116116
- 🍁 `decryptHmacAes(value: string, privateKey: string) -> use only for HMAC_AES`
117117
- 🍁 `verifyHmac(value: string, privateKey: string) -> use only for HMAC`
118118
```js
119-
import Encryption from 'react-native-encryption-algorithm';
119+
import Crypto from 'react-native-crypto-algorithm';
120120

121121
// Generate HMAC & HMAC_AES
122-
let genHmacSecretKey = await Encryption.genHmacSecretKey();
122+
let genHmacSecretKey = await Crypto.genHmacSecretKey();
123123

124124
// Encrypt HMAC_AES
125-
let encryptData = await Encryption.encryptHmacAes('my message', genHmacSecretKey);
125+
let encryptData = await Crypto.encryptHmacAes('my message', genHmacSecretKey);
126126

127127
// Decrypt HMAC_AES
128-
let decryptData = await Encryption.decryptHmacAes(encryptData, genHmacSecretKey);
128+
let decryptData = await Crypto.decryptHmacAes(encryptData, genHmacSecretKey);
129129

130130
// VerifyHmac HMAC
131-
let verifyHmacData: boolean = await Encryption.verifyHmac('my message', genHmacSecretKey);
131+
let verifyHmacData: boolean = await Crypto.verifyHmac('my message', genHmacSecretKey);
132132
```
133133

134134
---

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-crypto-algorithm",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Native Module using Kotlin & Swift for React-Native",
55
"source": "./src/index.tsx",
66
"main": "./lib/commonjs/index.js",

src/CryptoAlgorithm.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ interface CryptoAlgorithmInterface {
99
genRSAKeyPair(): Promise<any>;
1010
encryptRSA(value: string, publicKey: string): Promise<string|null>;
1111
decryptRSA(value: string, privateKey: string): Promise<string|null>;
12+
genHmacSecretKey(): Promise<null>;
13+
encryptHmacAes(value: string, privateKey: string): Promise<string|null>;
14+
decryptHmacAes(value: string, privateKey: string): Promise<string|null>;
15+
verifyHmac(value: string, privateKey: string): Promise<string|null>;
1216
}
1317

1418
export default CryptoAlgorithm as CryptoAlgorithmInterface;

src/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { NativeModules } from 'react-native';
22

33
const CryptoAlgorithmNative = NativeModules.CryptoAlgorithm;
44

5-
export default class Encryption {
5+
export default class Crypto {
66
static hashSHA256 = (value: string) => {
77
return CryptoAlgorithmNative.hashSHA256(value);
88
};

0 commit comments

Comments
 (0)