From 5e54b2866eb181e84de9910de06fd013a280a5c9 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期三, 05 三月 2025 16:18:36 +0800
Subject: [PATCH] 保存实体更新

---
 internal/vite-config/src/utils/hash.ts |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/internal/vite-config/src/utils/hash.ts b/internal/vite-config/src/utils/hash.ts
new file mode 100644
index 0000000..0b5a7c9
--- /dev/null
+++ b/internal/vite-config/src/utils/hash.ts
@@ -0,0 +1,16 @@
+import { createHash } from 'node:crypto';
+
+function createContentHash(content: string, hashLSize = 12) {
+  const hash = createHash('sha256').update(content);
+  return hash.digest('hex').slice(0, hashLSize);
+}
+function strToHex(str: string) {
+  const result: string[] = [];
+  for (let i = 0; i < str.length; ++i) {
+    const hex = str.charCodeAt(i).toString(16);
+    result.push(('000' + hex).slice(-4));
+  }
+  return result.join('').toUpperCase();
+}
+
+export { createContentHash, strToHex };

--
Gitblit v1.9.3