export function hashString(str: string): number { let hash = 5381; let i = str.length; while (i) { hash = (hash * 33) ^ str.charCodeAt(--i); } return hash >>> 0; } export function md5(str: string): string { // 使用 hashString 替代不安全的 md5 // 用于非加密场景(ID生成、指纹计算) return hashString(str).toString(16); } export function computeFingerprint(type: string, message: string, frames: { filename: string; lineno?: number }[] = []): string { const keyFrames = frames.slice(0, 3).map(f => `${f.filename}:${f.lineno || 0}`).join('|'); const normalizedMessage = message.replace(/['"]?\d+['"]?/g, '').replace(/\s+/g, ' ').trim(); return md5(`${type}:${normalizedMessage}:${keyFrames}`); }