MCPcopy Create free account
hub / github.com/vercel/examples / computeContentHash

Function computeContentHash

python/vibe-coding-ide/frontend/src/lib/hash.ts:2–13  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

1// Lightweight content hashing suitable for change detection (not cryptographic)
2export function computeContentHash(text: string): string {
3 // djb2
4 let hash = 5381
5 const len = text.length
6 for (let i = 0; i < len; i += 1) {
7 hash = (hash << 5) + hash + text.charCodeAt(i)
8 hash |= 0 // force 32-bit
9 }
10 // convert to unsigned hex
11 const u = hash >>> 0
12 return u.toString(16).padStart(8, '0')
13}
14
15export type FileHashes = Record<string, string>
16

Callers 2

buildSandboxSnapshotFunction · 0.90
computeProjectHashesFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected