MCPcopy
hub / github.com/SPlayer-Dev/SPlayer / getFileID

Function getFileID

electron/main/utils/helper.ts:9–17  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

7 * @returns 唯一ID
8 */
9export const getFileID = (filePath: string): number => {
10 // SHA-256
11 const hash = createHash("sha256");
12 hash.update(filePath);
13 const digest = hash.digest("hex");
14 // 将哈希值的前 16 位转换为十进制数字
15 const uniqueId = parseInt(digest.substring(0, 16), 16);
16 return Number(uniqueId.toString().padStart(16, "0"));
17};
18
19/**
20 * 生成文件 MD5

Callers 1

scanDirectoryMethod · 0.90

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected