Files
SnowLuma/.pnpm-store/v11/files/04/9c2cd87db2f218b8efa6edd37561e4fbaa45810ad7441e1f23563949f4ff73219f0c2ce2233c90e32e517668df793e1c45cbc2d45ede1a9fbfaeceba8fce95
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

41 lines
1.2 KiB
Plaintext

import uppercaseVariant from './variants/scoring/uppercase'
import l33tVariant from './variants/scoring/l33t'
import {
DictionaryScoringExtras,
MatchEstimated,
MatchExtended,
} from '../../types'
export interface DictionaryReturn extends DictionaryScoringExtras {
calculation: number
}
export default ({
rank,
reversed,
l33t,
subs,
token,
dictionaryName,
}: MatchExtended | MatchEstimated): DictionaryReturn => {
const baseGuesses = rank // keep these as properties for display purposes
const uppercaseVariations = uppercaseVariant(token)
const l33tVariations = l33tVariant({ l33t, subs, token })
const reversedVariations = (reversed && 2) || 1
let calculation
if (dictionaryName === 'diceware') {
// diceware dictionaries are special, so we get a simple scoring of 1/2 of 6^5 (6 digits on 5 dice)
// to get fix entropy of ~12.9 bits for every entry https://en.wikipedia.org/wiki/Diceware#:~:text=The%20level%20of,bits
calculation = 6 ** 5 / 2
} else {
calculation =
baseGuesses * uppercaseVariations * l33tVariations * reversedVariations
}
return {
baseGuesses,
uppercaseVariations,
l33tVariations,
calculation,
}
}