更新依赖项版本,添加文件哈希功能,优化远程应用连接逻辑

This commit is contained in:
2026-01-26 04:18:03 +08:00
parent 48dafc6040
commit 15d81c4f68
7 changed files with 174 additions and 35 deletions

View File

@@ -0,0 +1,16 @@
import crypto from 'node:crypto';
import fs from 'node:fs';
export const getHash = (file: string) => {
if (!fs.existsSync(file)) return '';
const buffer = fs.readFileSync(file); // 不指定编码,返回 Buffer
return crypto.createHash('md5').update(buffer).digest('hex');
};
export const getBufferHash = (buffer: Buffer) => {
return crypto.createHash('md5').update(buffer).digest('hex');
};
export const getStringHash = (str: string) => {
return crypto.createHash('md5').update(str).digest('hex');
}