1
1
# react-native-crypto-algorithm
2
2
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 )
4
4
[ ![ ] ( https://img.shields.io/badge/native_language-Kotlin_&_Swift-green )] ( https://www.npmjs.com/package/react-native-encryption-algorithm )
5
5
[ ![ ] ( https://img.shields.io/badge/size-72.7_kB-red )] ( https://www.npmjs.com/package/react-native-encryption-algorithm )
6
6
[ ![ ] ( https://img.shields.io/badge/license-MIT-8A2BE2 )] ( https://github.com/LamNguyen17/react-native-encryption-algorithm/blob/master/LICENSE )
7
7
[ ![ ] ( https://img.shields.io/badge/author-Forest_Nguyen-f59642 )] ( https://github.com/LamNguyen17 )
8
8
9
9
## Installation
10
10
``` sh
11
- npm install react-native-encryption -algorithm
11
+ npm install react-native-crypto -algorithm
12
12
```
13
13
or
14
14
``` sh
15
- yarn add react-native-encryption -algorithm
15
+ yarn add react-native-crypto -algorithm
16
16
```
17
17
18
18
### Installation (iOS)
@@ -26,7 +26,7 @@ pod install
26
26
27
27
##### Using React Native Link (React Native 0.59 and lower)
28
28
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.
30
30
31
31
### Installation (Android)
32
32
@@ -40,8 +40,8 @@ Run `react-native link react-native-encryption-algorithm` after which you should
40
40
41
41
``` gradle
42
42
...
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')
45
45
```
46
46
47
47
- In ` android/app/build.gradle `
@@ -50,19 +50,19 @@ project(':react-native-encryption-algorithm').projectDir = new File(rootProject.
50
50
...
51
51
dependencies {
52
52
...
53
- compile project(':react-native-encryption -algorithm')
53
+ compile project(':react-native-crypto -algorithm')
54
54
}
55
55
```
56
56
- register module (in MainApplication.kt)
57
57
58
58
``` kt
59
59
......
60
- import com.encryptionalgorithm.EncryptionAlgorithmPackage ;
60
+ import com.cryptoalgorithm.CryptoAlgorithmPackage ;
61
61
......
62
62
63
63
override fun getPackages (): List <ReactPackage > =
64
64
PackageList (this ).packages.apply {
65
- add(EncryptionAlgorithmPackage ());
65
+ add(CryptoAlgorithmPackage ());
66
66
}
67
67
```
68
68
@@ -75,39 +75,39 @@ override fun getPackages(): List<ReactPackage> =
75
75
- 🍁 ` encryptAES(value: string, secretKey: string, ivKey?: string) `
76
76
- 🍁 ` decryptAES(value: string, secretKey: string, ivKey?: string) `
77
77
``` js
78
- import Encryption from ' react-native-encryption -algorithm' ;
78
+ import Crypto from ' react-native-crypto -algorithm' ;
79
79
80
80
// 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)' );
82
82
83
83
// 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)' );
85
85
```
86
86
87
87
#### 🚀 SHA256
88
88
- 🍁 ` hashSHA256(value: string) `
89
89
``` js
90
- import Encryption from ' react-native-encryption -algorithm' ;
90
+ import Crypto from ' react-native-crypto -algorithm' ;
91
91
92
92
// Hash SHA256
93
- let hashData = await Encryption .hashSHA256 (' my hash data' );
93
+ let hashData = await Crypto .hashSHA256 (' my hash data' );
94
94
```
95
95
96
96
#### 🚀 RSA
97
97
- 🍁 ` genRSAKeyPair() `
98
98
- 🍁 ` encryptRSA(value: string, publicKey: string) `
99
99
- 🍁 ` decryptRSA(value: string, privateKey: string) `
100
100
``` js
101
- import Encryption from ' react-native-encryption -algorithm' ;
101
+ import Crypto from ' react-native-crypto -algorithm' ;
102
102
103
103
// Generate RSA Key Pair
104
- let keyPair = await Encryption .genRSAKeyPair ();
104
+ let keyPair = await Crypto .genRSAKeyPair ();
105
105
106
106
// Encrypt RSA
107
- let encryptData = await Encryption .encryptRSA (' my message' , keyPair .publicKey );
107
+ let encryptData = await Crypto .encryptRSA (' my message' , keyPair .publicKey );
108
108
109
109
// Decrypt RSA
110
- let decryptData = await Encryption .decryptRSA (encryptData, keyPair .privateKey );
110
+ let decryptData = await Crypto .decryptRSA (encryptData, keyPair .privateKey );
111
111
```
112
112
113
113
#### 🚀 HMAC / HMAC_AES
@@ -116,19 +116,19 @@ let decryptData = await Encryption.decryptRSA(encryptData, keyPair.privateKey);
116
116
- 🍁 ` decryptHmacAes(value: string, privateKey: string) -> use only for HMAC_AES `
117
117
- 🍁 ` verifyHmac(value: string, privateKey: string) -> use only for HMAC `
118
118
``` js
119
- import Encryption from ' react-native-encryption -algorithm' ;
119
+ import Crypto from ' react-native-crypto -algorithm' ;
120
120
121
121
// Generate HMAC & HMAC_AES
122
- let genHmacSecretKey = await Encryption .genHmacSecretKey ();
122
+ let genHmacSecretKey = await Crypto .genHmacSecretKey ();
123
123
124
124
// Encrypt HMAC_AES
125
- let encryptData = await Encryption .encryptHmacAes (' my message' , genHmacSecretKey);
125
+ let encryptData = await Crypto .encryptHmacAes (' my message' , genHmacSecretKey);
126
126
127
127
// Decrypt HMAC_AES
128
- let decryptData = await Encryption .decryptHmacAes (encryptData, genHmacSecretKey);
128
+ let decryptData = await Crypto .decryptHmacAes (encryptData, genHmacSecretKey);
129
129
130
130
// VerifyHmac HMAC
131
- let verifyHmacData: boolean = await Encryption .verifyHmac (' my message' , genHmacSecretKey);
131
+ let verifyHmacData: boolean = await Crypto .verifyHmac (' my message' , genHmacSecretKey);
132
132
```
133
133
134
134
---
0 commit comments