forked from ghbutton/react-native-simple-crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
72 lines (65 loc) · 2.15 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
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 namespace SHA {
export function sha1(text: string): Promise<string>;
export function sha256(text: string): Promise<string>;
export function sha512(text: string): Promise<string>;
}
export namespace HMAC {
export function hmac256(
ciphertext: ArrayBuffer,
key: ArrayBuffer
): Promise<ArrayBuffer>;
}
export namespace PBKDF2 {
export function hash(
password: string,
salt: ArrayBuffer,
iterations: number,
keyLen: number,
hash: "SHA1" | "SHA224" | "SHA256" | "SHA384" | "SHA512"
): Promise<ArrayBuffer>;
}
export namespace RSA {
export function generateKeys(keySize: number): Promise<KeyPair>;
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;
}
}