forked from ghbutton/react-native-simple-crypto
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.d.ts
87 lines (80 loc) · 2.72 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
declare module "react-native-simple-crypto" {
interface PublicKey {
public: string;
}
interface KeyPair extends PublicKey {
private: string;
}
export namespace AES {
export function encrypt(
text: ArrayBuffer,
key: ArrayBuffer,
iv: ArrayBuffer
): Promise<ArrayBuffer>;
export function decrypt(
ciphertext: ArrayBuffer,
key: ArrayBuffer,
iv: ArrayBuffer
): Promise<ArrayBuffer>;
export function encryptFile(
filePath: string,
key: string,
iv: string
): Promise<string>;
export function decryptFile(
filePath: string,
key: string,
iv: string
): Promise<string>;
}
export namespace SHA {
export function sha1(text: string): Promise<string>;
export function sha1(text: ArrayBuffer): Promise<ArrayBuffer>;
export function sha256(text: string): Promise<string>;
export function sha256(text: ArrayBuffer): Promise<ArrayBuffer>;
export function sha512(text: string): Promise<string>;
export function sha512(text: ArrayBuffer): Promise<ArrayBuffer>;
}
export namespace HMAC {
export function hmac256(
ciphertext: ArrayBuffer,
key: ArrayBuffer
): Promise<ArrayBuffer>;
}
export namespace PBKDF2 {
export function hash(
password: string | ArrayBuffer,
salt: string | ArrayBuffer,
iterations: number,
keyLen: number,
algorithm: "SHA1" | "SHA224" | "SHA256" | "SHA384" | "SHA512"
): Promise<ArrayBuffer>;
}
export namespace RSA {
export function generateKeys(keySize: number): Promise<KeyPair>;
export function importKey(jwk: any): Promise<string>;
export function exportKey(pkcs1: string): Promise<any>;
export function encrypt(data: string, key: string): Promise<string>;
export function decrypt(data: string, key: string): Promise<string>;
export function sign(
data: string,
key: string,
hash: "Raw" | "SHA1" | "SHA224" | "SHA256" | "SHA384" | "SHA512"
): Promise<string>;
export function verify(
data: string,
secretToVerify: string,
key: string,
hash: "Raw" | "SHA1" | "SHA224" | "SHA256" | "SHA384" | "SHA512"
): Promise<boolean>;
}
export namespace utils {
export function randomBytes(bytes: number): Promise<ArrayBuffer>;
export function convertArrayBufferToUtf8(input: ArrayBuffer): string;
export function convertUtf8ToArrayBuffer(input: string): ArrayBuffer;
export function convertArrayBufferToBase64(input: ArrayBuffer): string;
export function convertBase64ToArrayBuffer(input: string): ArrayBuffer;
export function convertArrayBufferToHex(input: ArrayBuffer): string;
export function convertHexToArrayBuffer(input: string): ArrayBuffer;
}
}