diff --git a/types/crypto-js/crypto-js-tests.ts b/types/crypto-js/crypto-js-tests.ts index c36def9f90..9b5dd1be6f 100644 --- a/types/crypto-js/crypto-js-tests.ts +++ b/types/crypto-js/crypto-js-tests.ts @@ -11,6 +11,10 @@ wordArray = CryptoJS.SHA1('some message', 'some key', { any: true }); wordArray = CryptoJS.format.OpenSSL('some message'); wordArray = CryptoJS.format.OpenSSL('some message', 'some key'); +var FR = new FileReader(); +FR.onloadend = () => { + var hash = CryptoJS.SHA1(CryptoJS.lib.WordArray.create(FR.result)).toString() +} // Ciphers var encrypted: CryptoJS.WordArray; diff --git a/types/crypto-js/index.d.ts b/types/crypto-js/index.d.ts index 8e80c74a07..4e35dfbdfb 100644 --- a/types/crypto-js/index.d.ts +++ b/types/crypto-js/index.d.ts @@ -8,7 +8,7 @@ export as namespace CryptoJS; declare var CryptoJS: CryptoJS.Hashes; declare namespace CryptoJS { - type Hash = (message: string, key?: string, ...options: any[]) => WordArray; + type Hash = (message: string | LibWordArray, key?: string, ...options: any[]) => WordArray; interface Cipher { encrypt(message: string, secretPassphrase: string, option?: CipherOption): WordArray; decrypt(encryptedMessage: string | WordArray, secretPassphrase: string, option?: CipherOption): DecryptedMessage; @@ -25,6 +25,10 @@ declare namespace CryptoJS { process(messagePart: string): string; finalize(): string; } + interface LibWordArray { + sigBytes: number, + words: number[], + } export interface WordArray { iv: string; salt: string; @@ -97,6 +101,11 @@ declare namespace CryptoJS { Utf16LE: Encoder; Base64: Encoder; }; + lib: { + WordArray: { + create: (v: any) => LibWordArray; + }; + }; mode: { CBC: Mode; CFB: Mode;