|
1 | 1 | import { NativeModules } from 'react-native';
|
2 | 2 |
|
3 |
| -const CryptoAlgorithmNative = NativeModules.CryptoAlgorithm; |
| 3 | +const { CryptoAlgorithm } = NativeModules; |
4 | 4 |
|
5 | 5 | export default class Crypto {
|
6 | 6 | static hashSHA256 = (value: string) => {
|
7 |
| - return CryptoAlgorithmNative.hashSHA256(value); |
| 7 | + return CryptoAlgorithm.hashSHA256(value); |
8 | 8 | };
|
9 | 9 |
|
10 | 10 | static encryptAES = (value: string, secretKey: string, ivKey?: string) => {
|
11 |
| - return CryptoAlgorithmNative.encryptAES(value, secretKey, ivKey); |
| 11 | + return CryptoAlgorithm.encryptAES(value, secretKey, ivKey); |
12 | 12 | };
|
13 | 13 |
|
14 | 14 | static decryptAES = (value: string, secretKey: string, ivKey?: string) => {
|
15 |
| - return CryptoAlgorithmNative.decryptAES(value, secretKey, ivKey); |
| 15 | + return CryptoAlgorithm.decryptAES(value, secretKey, ivKey); |
16 | 16 | };
|
17 | 17 |
|
18 | 18 | static genRSAKeyPair = () => {
|
19 |
| - return CryptoAlgorithmNative.genRSAKeyPair(); |
| 19 | + return CryptoAlgorithm.genRSAKeyPair(); |
20 | 20 | };
|
21 | 21 |
|
22 | 22 | static encryptRSA = (value: string, publicKey: string) => {
|
23 |
| - return CryptoAlgorithmNative.encryptRSA(value, publicKey); |
| 23 | + return CryptoAlgorithm.encryptRSA(value, publicKey); |
24 | 24 | };
|
25 | 25 |
|
26 | 26 | static decryptRSA = (value: any, privateKey: string) => {
|
27 |
| - return CryptoAlgorithmNative.decryptRSA(value, privateKey); |
| 27 | + return CryptoAlgorithm.decryptRSA(value, privateKey); |
28 | 28 | };
|
29 | 29 |
|
30 | 30 | static genHmacSecretKey = () => {
|
31 |
| - return CryptoAlgorithmNative.genSecretKey('Hmac'); |
| 31 | + return CryptoAlgorithm.genSecretKey('Hmac'); |
32 | 32 | };
|
33 | 33 |
|
34 | 34 | static encryptHmacAes = (value: string, privateKey: string)=> {
|
35 |
| - return CryptoAlgorithmNative.encryptHmacAes(value, privateKey); |
| 35 | + return CryptoAlgorithm.encryptHmacAes(value, privateKey); |
36 | 36 | };
|
37 | 37 |
|
38 | 38 | static decryptHmacAes = (value: any, privateKey: string) => {
|
39 |
| - return CryptoAlgorithmNative.decryptHmacAes(value, privateKey); |
| 39 | + return CryptoAlgorithm.decryptHmacAes(value, privateKey); |
40 | 40 | };
|
41 | 41 |
|
42 | 42 | static verifyHmac = (value: string, privateKey: string) => {
|
43 |
| - return CryptoAlgorithmNative.verifyHmac(value, privateKey); |
| 43 | + return CryptoAlgorithm.verifyHmac(value, privateKey); |
44 | 44 | };
|
45 | 45 | }
|
0 commit comments