Function
collisionRisk
(
code: string,
entropy: number
)
Source from the content-addressed store, hash-verified
| 42 | } |
| 43 | |
| 44 | function collisionRisk( |
| 45 | code: string, |
| 46 | entropy: number |
| 47 | ): 'low' | 'medium' | 'high' { |
| 48 | if (code.length === 4) { |
| 49 | // Max entropy ~8 bits |
| 50 | if (entropy > 6.5) return 'low' |
| 51 | if (entropy > 3.5) return 'medium' |
| 52 | return 'high' |
| 53 | } |
| 54 | |
| 55 | if (code.length === 6) { |
| 56 | // Max entropy ~12 bits |
| 57 | if (entropy > 10) return 'low' |
| 58 | if (entropy > 6) return 'medium' |
| 59 | return 'high' |
| 60 | } |
| 61 | |
| 62 | return 'high' |
| 63 | } |
| 64 | |
| 65 | function memorabilityScore( |
| 66 | code: string, |
Tested by
no test coverage detected