MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / calculateHashFromArrayBuffer

Function calculateHashFromArrayBuffer

src/pkg/utils/crypto.ts:28–52  ·  view source on GitHub ↗
(a: ArrayBuffer)

Source from the content-addressed store, hash-verified

26}
27
28export 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}

Callers 2

crypto.test.tsFile · 0.90
calculateHashMethod · 0.90

Calls 1

createMethod · 0.65

Tested by

no test coverage detected