commit
a22cb81b2e
|
@ -1,12 +1,11 @@
|
||||||
package entropy
|
package entropy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestDictionaryEntropyCalculation(t *testing.T) {
|
func TestDictionaryEntropyCalculation(t *testing.T) {
|
||||||
match := match.Match{
|
match := match.Match{
|
||||||
Pattern: "dictionary",
|
Pattern: "dictionary",
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func checkDate(day, month, year int64) (bool, int64, int64, int64) {
|
func checkDate(day, month, year int64) (bool, int64, int64, int64) {
|
||||||
if (12 <= month && month <= 31) && day <= 12 {
|
if (12 <= month && month <= 31) && day <= 12 {
|
||||||
day, month = month, day
|
day, month = month, day
|
||||||
|
@ -97,7 +95,8 @@ type DateMatchCandidateTwo struct {
|
||||||
Year string
|
Year string
|
||||||
I, J int
|
I, J int
|
||||||
}
|
}
|
||||||
func dateWithoutSepMatch(password string) ([]match.Match) {
|
|
||||||
|
func dateWithoutSepMatch(password string) []match.Match {
|
||||||
dateMatches := dateWithoutSepMatchHelper(password)
|
dateMatches := dateWithoutSepMatchHelper(password)
|
||||||
|
|
||||||
var matches []match.Match
|
var matches []match.Match
|
||||||
|
@ -115,6 +114,7 @@ func dateWithoutSepMatch(password string) ([]match.Match) {
|
||||||
|
|
||||||
return matches
|
return matches
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Has issues with 6 digit dates
|
//TODO Has issues with 6 digit dates
|
||||||
func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
|
func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
|
||||||
matcher := regexp.MustCompile(DATE_WITHOUT_SEP_MATCH)
|
matcher := regexp.MustCompile(DATE_WITHOUT_SEP_MATCH)
|
||||||
|
@ -140,7 +140,6 @@ func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
|
||||||
candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[0:lastIndex-3], v[lastIndex-3:], i, j))
|
candidatesRoundOne = append(candidatesRoundOne, buildDateMatchCandidate(v[0:lastIndex-3], v[lastIndex-3:], i, j))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var candidatesRoundTwo []DateMatchCandidateTwo
|
var candidatesRoundTwo []DateMatchCandidateTwo
|
||||||
for _, c := range candidatesRoundOne {
|
for _, c := range candidatesRoundOne {
|
||||||
if len(c.DayMonth) == 2 {
|
if len(c.DayMonth) == 2 {
|
||||||
|
@ -159,14 +158,12 @@ func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
intMonth, err := strconv.ParseInt(candidate.Month, 10, 16)
|
intMonth, err := strconv.ParseInt(candidate.Month, 10, 16)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
intYear, err := strconv.ParseInt(candidate.Year, 10, 16)
|
intYear, err := strconv.ParseInt(candidate.Year, 10, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func l33tMatch(password string) []match.Match {
|
func l33tMatch(password string) []match.Match {
|
||||||
|
|
||||||
substitutions := relevantL33tSubtable(password)
|
substitutions := relevantL33tSubtable(password)
|
||||||
|
|
|
@ -74,6 +74,4 @@ func loadFrequencyList() {
|
||||||
MATCHERS = append(MATCHERS, dateSepMatcher)
|
MATCHERS = append(MATCHERS, dateSepMatcher)
|
||||||
MATCHERS = append(MATCHERS, dateWithoutSepMatch)
|
MATCHERS = append(MATCHERS, dateWithoutSepMatch)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"fmt"
|
|
||||||
"encoding/json"
|
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//DateSepMatch("1991-09-11jibjab11.9.1991")
|
//DateSepMatch("1991-09-11jibjab11.9.1991")
|
||||||
|
@ -123,12 +123,10 @@ func TestDateWithoutSepMatch(t *testing.T) {
|
||||||
matches := dateWithoutSepMatch("11091991")
|
matches := dateWithoutSepMatch("11091991")
|
||||||
assert.Len(t, matches, 1, "Lenght should be 1")
|
assert.Len(t, matches, 1, "Lenght should be 1")
|
||||||
|
|
||||||
|
|
||||||
matches = dateWithoutSepMatch("20010911")
|
matches = dateWithoutSepMatch("20010911")
|
||||||
assert.Len(t, matches, 1, "Lenght should be 1")
|
assert.Len(t, matches, 1, "Lenght should be 1")
|
||||||
log.Println(matches)
|
log.Println(matches)
|
||||||
|
|
||||||
|
|
||||||
//matches := dateWithoutSepMatch("110991")
|
//matches := dateWithoutSepMatch("110991")
|
||||||
//assert.Len(t, matches, 21, "Lenght should be blarg")
|
//assert.Len(t, matches, 21, "Lenght should be blarg")
|
||||||
}
|
}
|
||||||
|
@ -146,12 +144,10 @@ func TestLeetSubTable(t *testing.T){
|
||||||
assert.Equal(t, subs["i"][0], "1")
|
assert.Equal(t, subs["i"][0], "1")
|
||||||
assert.Equal(t, subs["l"][0], "1")
|
assert.Equal(t, subs["l"][0], "1")
|
||||||
|
|
||||||
|
|
||||||
subs = relevantL33tSubtable("4pple@pple")
|
subs = relevantL33tSubtable("4pple@pple")
|
||||||
assert.Len(t, subs, 1, "4pple@pple should produce 1 subs")
|
assert.Len(t, subs, 1, "4pple@pple should produce 1 subs")
|
||||||
assert.Len(t, subs["a"], 2)
|
assert.Len(t, subs["a"], 2)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPermutationsOfLeetSubstitutions(t *testing.T) {
|
func TestPermutationsOfLeetSubstitutions(t *testing.T) {
|
||||||
|
@ -174,7 +170,6 @@ func TestPermutationsOfLeetSubstitutions(t *testing.T){
|
||||||
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
||||||
assert.Len(t, permutations, 15, "Check my math 2*2*2*2 - 1 "+password)
|
assert.Len(t, permutations, 15, "Check my math 2*2*2*2 - 1 "+password)
|
||||||
|
|
||||||
|
|
||||||
password = "1337"
|
password = "1337"
|
||||||
possibleSubs = relevantL33tSubtable(password)
|
possibleSubs = relevantL33tSubtable(password)
|
||||||
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func repeatMatch(password string) []match.Match {
|
func repeatMatch(password string) []match.Match {
|
||||||
var matches []match.Match
|
var matches []match.Match
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func sequenceMatch(password string) []match.Match {
|
func sequenceMatch(password string) []match.Match {
|
||||||
var matches []match.Match
|
var matches []match.Match
|
||||||
for i := 0; i < len(password); {
|
for i := 0; i < len(password); {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package matching
|
package matching
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nbutton23/zxcvbn-go/match"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/entropy"
|
|
||||||
"strings"
|
|
||||||
"github.com/nbutton23/zxcvbn-go/adjacency"
|
"github.com/nbutton23/zxcvbn-go/adjacency"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/entropy"
|
||||||
|
"github.com/nbutton23/zxcvbn-go/match"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func spatialMatch(password string) (matches []match.Match) {
|
func spatialMatch(password string) (matches []match.Match) {
|
||||||
|
@ -78,4 +78,3 @@ func spatialMatchHelper(password string, graph adjacency.AdjacencyGraph) (matche
|
||||||
}
|
}
|
||||||
return matches
|
return matches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func PasswordStrength(password string, userInputs []string) scoring.MinEntropyMatch {
|
func PasswordStrength(password string, userInputs []string) scoring.MinEntropyMatch {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
matches := matching.Omnimatch(password, userInputs)
|
matches := matching.Omnimatch(password, userInputs)
|
||||||
|
|
Loading…
Reference in New Issue