( messageText: string, version: string, )
| 48 | * @returns 3-character hex fingerprint |
| 49 | */ |
| 50 | export function computeFingerprint( |
| 51 | messageText: string, |
| 52 | version: string, |
| 53 | ): string { |
| 54 | // Extract chars at indices [4, 7, 20], use "0" if index not found |
| 55 | const indices = [4, 7, 20] |
| 56 | const chars = indices.map(i => messageText[i] || '0').join('') |
| 57 | |
| 58 | const fingerprintInput = `${FINGERPRINT_SALT}${chars}${version}` |
| 59 | |
| 60 | // SHA256 hash, return first 3 hex chars |
| 61 | const hash = createHash('sha256').update(fingerprintInput).digest('hex') |
| 62 | return hash.slice(0, 3) |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Computes fingerprint from the first user message. |
no test coverage detected