Merge pull request #17 from shawnps/master

gofmt -s
This commit is contained in:
Nathan Button 2016-06-26 18:44:24 -06:00 committed by GitHub
commit a22cb81b2e
13 changed files with 81 additions and 96 deletions

View File

@ -1,12 +1,11 @@
package entropy
import (
"github.com/stretchr/testify/assert"
"github.com/nbutton23/zxcvbn-go/match"
"github.com/stretchr/testify/assert"
"testing"
)
func TestDictionaryEntropyCalculation(t *testing.T) {
match := match.Match{
Pattern: "dictionary",

View File

@ -1,15 +1,13 @@
package matching
import (
"github.com/nbutton23/zxcvbn-go/entropy"
"github.com/nbutton23/zxcvbn-go/match"
"strings"
"regexp"
"strconv"
"github.com/nbutton23/zxcvbn-go/entropy"
"strings"
)
func checkDate(day, month, year int64) (bool, int64, int64, int64) {
if (12 <= month && month <= 31) && day <= 12 {
day, month = month, day
@ -97,7 +95,8 @@ type DateMatchCandidateTwo struct {
Year string
I, J int
}
func dateWithoutSepMatch(password string) ([]match.Match) {
func dateWithoutSepMatch(password string) []match.Match {
dateMatches := dateWithoutSepMatchHelper(password)
var matches []match.Match
@ -115,6 +114,7 @@ func dateWithoutSepMatch(password string) ([]match.Match) {
return matches
}
//TODO Has issues with 6 digit dates
func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
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))
}
var candidatesRoundTwo []DateMatchCandidateTwo
for _, c := range candidatesRoundOne {
if len(c.DayMonth) == 2 {
@ -159,14 +158,12 @@ func dateWithoutSepMatchHelper(password string) (matches []match.DateMatch) {
continue
}
intMonth, err := strconv.ParseInt(candidate.Month, 10, 16)
if err != nil {
continue
}
intYear, err := strconv.ParseInt(candidate.Year, 10, 16)
if err != nil {
continue

View File

@ -1,8 +1,8 @@
package matching
import (
"github.com/nbutton23/zxcvbn-go/match"
"github.com/nbutton23/zxcvbn-go/entropy"
"github.com/nbutton23/zxcvbn-go/match"
"strings"
)

View File

@ -1,11 +1,11 @@
package matching
import (
"github.com/nbutton23/zxcvbn-go/match"
"github.com/nbutton23/zxcvbn-go/entropy"
"github.com/nbutton23/zxcvbn-go/match"
"strings"
)
func l33tMatch(password string) []match.Match {
substitutions := relevantL33tSubtable(password)

View File

@ -74,6 +74,4 @@ func loadFrequencyList() {
MATCHERS = append(MATCHERS, dateSepMatcher)
MATCHERS = append(MATCHERS, dateWithoutSepMatch)
}

View File

@ -1,13 +1,13 @@
package matching
import (
"github.com/stretchr/testify/assert"
"encoding/json"
"fmt"
"github.com/nbutton23/zxcvbn-go/match"
"github.com/stretchr/testify/assert"
"log"
"strings"
"testing"
"fmt"
"encoding/json"
"log"
)
//DateSepMatch("1991-09-11jibjab11.9.1991")
@ -123,12 +123,10 @@ func TestDateWithoutSepMatch(t *testing.T) {
matches := dateWithoutSepMatch("11091991")
assert.Len(t, matches, 1, "Lenght should be 1")
matches = dateWithoutSepMatch("20010911")
assert.Len(t, matches, 1, "Lenght should be 1")
log.Println(matches)
//matches := dateWithoutSepMatch("110991")
//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["l"][0], "1")
subs = relevantL33tSubtable("4pple@pple")
assert.Len(t, subs, 1, "4pple@pple should produce 1 subs")
assert.Len(t, subs["a"], 2)
}
func TestPermutationsOfLeetSubstitutions(t *testing.T) {
@ -174,7 +170,6 @@ func TestPermutationsOfLeetSubstitutions(t *testing.T){
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)
assert.Len(t, permutations, 15, "Check my math 2*2*2*2 - 1 "+password)
password = "1337"
possibleSubs = relevantL33tSubtable(password)
permutations = getAllPermutationsOfLeetSubstitutions(password, possibleSubs)

View File

@ -1,12 +1,11 @@
package matching
import (
"github.com/nbutton23/zxcvbn-go/match"
"github.com/nbutton23/zxcvbn-go/entropy"
"github.com/nbutton23/zxcvbn-go/match"
"strings"
)
func repeatMatch(password string) []match.Match {
var matches []match.Match

View File

@ -1,12 +1,11 @@
package matching
import (
"github.com/nbutton23/zxcvbn-go/match"
"github.com/nbutton23/zxcvbn-go/entropy"
"github.com/nbutton23/zxcvbn-go/match"
"strings"
)
func sequenceMatch(password string) []match.Match {
var matches []match.Match
for i := 0; i < len(password); {

View File

@ -1,10 +1,10 @@
package matching
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/entropy"
"github.com/nbutton23/zxcvbn-go/match"
"strings"
)
func spatialMatch(password string) (matches []match.Match) {
@ -78,4 +78,3 @@ func spatialMatchHelper(password string, graph adjacency.AdjacencyGraph) (matche
}
return matches
}

View File

@ -7,7 +7,6 @@ import (
"time"
)
func PasswordStrength(password string, userInputs []string) scoring.MinEntropyMatch {
start := time.Now()
matches := matching.Omnimatch(password, userInputs)