entropy/entropyCalculator.go
func ExtraLeetEntropy(match match.Match, password string) float64 {
	var subsitutions float64
	var unsub float64
	subPassword := password[match.I:match.J]
	for index, char := range subPassword {
		if string(char) != string(match.Token[index]) {
			subsitutions++
		} else {
			//TODO: Make this only true for 1337 chars that are not subs?
			unsub++
		}
	}

	var possibilities float64

	for i := float64(0); i <= math.Min(subsitutions, unsub)+1; i++ {
		possibilities += zxcvbnmath.NChoseK(subsitutions+unsub, i)
	}

	if possibilities <= 1 {
		return float64(1)
	}
	return math.Log2(possibilities)
}
func ExtraLeetEntropy(match match.Match, password string) float64 {
	var subsitutions float64
	var unsub float64
	subPassword := password[match.I:match.J]
	for index, char := range subPassword {
		if string(char) != string(match.Token[index]) {
			subsitutions++
		} else {
			//TODO: Make this only true for 1337 chars that are not subs?
			unsub++
		}
	}

	var possibilities float64

	for i := float64(0); i <= math.Min(subsitutions, unsub)+1; i++ {
		possibilities += zxcvbnmath.NChoseK(subsitutions+unsub, i)
	}

	if possibilities <= 1 {
		return float64(1)
	}
	return math.Log2(possibilities)
}
func ExtraLeetEntropy ( match match . Match , password string ) float64 { var subsitutions float64 var unsub float64 subPassword := password [ match . I : match . J ] for index , char := range subPassword { if string ( char ) != string ( match . Token [ index ] ) { subsitutions ++ } else { //TODO: Make this only true for 1337 chars that are not subs? unsub ++ } } var possibilities float64 for i := float64 ( 0 ) ; i <= math . Min ( subsitutions , unsub ) + 1 ; i ++ { possibilities += zxcvbnmath . NChoseK ( subsitutions + unsub , i ) } if possibilities <= 1 { return float64 ( 1 ) } return math . Log2 ( possibilities ) }
// ExtraLeetEntropy calulates the added entropy provied by l33t substitustions
ExtraLeetEntropy calulates the added entropy provied by l33t substitustions