forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jssha.d.ts
85 lines (73 loc) · 2.96 KB
/
jssha.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
// Type definitions for jsSHA
// Project: https://github.com/Caligatio/jsSHA
// Definitions by: David Li <https://github.com/randombk>, Tobias Kahlert <https://github.com/SrTobi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module jsSHA {
export interface EncodingOptions {
encoding? : string;
}
export interface Options extends EncodingOptions {
numRounds? : number;
}
export interface OutputFormatOptions {
outputUpper? : boolean;
b64Pad? : string;
}
export interface jsSHA {
/**
* jsSHA is the workhorse of the library. Instantiate it with the string to
* be hashed as the parameter
*
* @param {string} variant The desired SHA variant (SHA-1, SHA-224, SHA-256,
* SHA-384, or SHA-512)
* @param {string} inputFormat The format of srcString: HEX, TEXT, B64, or BYTES
* @param {{encoding: (string|undefined), numRounds: (string|undefined)}=}
* options Optional values
*/
new (variant:string, inputFormat:string, options?:Options):jsSHA;
/**
* Sets the HMAC key for an eventual getHMAC call. Must be called
* immediately after jsSHA object instantiation
*
* @param {string} key The key used to calculate the HMAC
* @param {string} inputFormat The format of key, HEX, TEXT, B64, or BYTES
* @param {{encoding : (string|undefined)}=} encodingOpts Associative array
* of input format options
*/
setHMACKey(key:string, inputFormat:string, encodingOpts?:EncodingOptions):void;
/**
* Takes strString and hashes as many blocks as possible. Stores the
* rest for either a future update or getHash call.
*
* @param {string} srcString The string to be hashed
*/
update(srcString:string):void;
/**
* Returns the desired SHA hash of the string specified at instantiation
* using the specified parameters
*
* @param {string} format The desired output formatting (B64, HEX, or BYTES)
* @param {{outputUpper : (boolean|undefined), b64Pad : (string|undefined)}=}
* outputFormatOpts Hash list of output formatting options
* @return {string} The string representation of the hash in the format
* specified
*/
getHash(format:string, outputFormatOpts?:OutputFormatOptions):string;
/**
* Returns the the HMAC in the specified format using the key given by
* a previous setHMACKey call.
*
* @param {string} format The desired output formatting
* (B64, HEX, or BYTES)
* @param {{outputUpper : (boolean|undefined), b64Pad : (string|undefined)}=}
* outputFormatOpts associative array of output formatting options
* @return {string} The string representation of the hash in the format
* specified
*/
getHMAC(format:string, outputFormatOpts?:OutputFormatOptions):string;
}
}
declare var jsSHA: jsSHA.jsSHA;
declare module 'jssha' {
export = jsSHA;
}