forked from rocwong-cn/react-native-aes-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
20 lines (20 loc) · 699 Bytes
/
index.js
File metadata and controls
20 lines (20 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
* Created by Roc on 2017/8/14.
* desc:
*/
import { NativeModules } from 'react-native';
const { AesCrypto } = NativeModules;
export default {
encrypt(plaintext, secretKey, iv) {
if (!plaintext || !secretKey || !iv) {
return Promise.reject(new Error("invalid parameter: plaintext,secretKey and iv are required"));
}
return AesCrypto.encrypt(plaintext, secretKey, iv);
},
decrypt(cipherText, secretKey, iv) {
if (!cipherText || !secretKey || !iv) {
return Promise.reject(new Error("invalid parameter: cipherText,secretKey and iv are required"));
}
return AesCrypto.decrypt(cipherText, secretKey, iv);
},
}