(a: ArrayBuffer)
| 26 | } |
| 27 | |
| 28 | export function calculateHashFromArrayBuffer(a: ArrayBuffer) { |
| 29 | const wordArray = crypto.lib.WordArray.create(<ArrayBuffer>a); |
| 30 | // 计算各种哈希值 |
| 31 | const ret = { |
| 32 | md5: crypto.MD5(wordArray), |
| 33 | sha1: crypto.SHA1(wordArray), |
| 34 | sha256: crypto.SHA256(wordArray), |
| 35 | sha384: crypto.SHA384(wordArray), |
| 36 | sha512: crypto.SHA512(wordArray), |
| 37 | }; |
| 38 | return { |
| 39 | md5: ret.md5.toString(), |
| 40 | sha1: ret.sha1.toString(), |
| 41 | sha256: ret.sha256.toString(), |
| 42 | sha384: ret.sha384.toString(), |
| 43 | sha512: ret.sha512.toString(), |
| 44 | integrity: { |
| 45 | md5: ret.md5.toString(crypto.enc.Base64), |
| 46 | sha1: ret.sha1.toString(crypto.enc.Base64), |
| 47 | sha256: ret.sha256.toString(crypto.enc.Base64), |
| 48 | sha384: ret.sha384.toString(crypto.enc.Base64), |
| 49 | sha512: ret.sha512.toString(crypto.enc.Base64), |
| 50 | }, |
| 51 | }; |
| 52 | } |
no test coverage detected