From a11d8f26cf341bf137be1bb7eab47716758fc80b Mon Sep 17 00:00:00 2001 From: ChenYe Date: Wed, 13 Apr 2022 22:35:28 +0800 Subject: [PATCH] add go.mod and remove unnecessary dep --- .../readline-pass-strength.go | 17 +++++------------ go.mod | 10 ++++++++++ go.sum | 6 ++++++ 3 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/example/readline-pass-strength/readline-pass-strength.go b/example/readline-pass-strength/readline-pass-strength.go index afcef45..dfd297d 100644 --- a/example/readline-pass-strength/readline-pass-strength.go +++ b/example/readline-pass-strength/readline-pass-strength.go @@ -23,7 +23,6 @@ import ( "fmt" "github.com/chzyer/readline" - zxcvbn "github.com/nbutton23/zxcvbn-go" ) const ( @@ -50,30 +49,24 @@ func Colorize(msg string, color int) string { func createStrengthPrompt(password []rune) string { symbol, color := "", Red - strength := zxcvbn.PasswordStrength(string(password), nil) switch { - case strength.Score <= 1: + case len(password) <= 1: symbol = "✗" color = Red - case strength.Score <= 2: + case len(password) <= 3: symbol = "⚡" color = Magenta - case strength.Score <= 3: + case len(password) <= 5: symbol = "⚠" color = Yellow - case strength.Score <= 4: + default: symbol = "✔" color = Green } prompt := Colorize(symbol, color) - if strength.Entropy > 0 { - entropy := fmt.Sprintf(" %3.0f", strength.Entropy) - prompt += Colorize(entropy, Cyan) - } else { - prompt += Colorize(" ENT", Cyan) - } + prompt += Colorize(" ENT", Cyan) prompt += Colorize(" New Password: ", color) return prompt diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a6c8dea --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/chzyer/readline + +go 1.15 + +require ( + github.com/chzyer/test v0.0.0-20210722231415-061457976a23 + golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 +) + +require github.com/chzyer/logex v1.2.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6a8821d --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/chzyer/logex v1.2.0 h1:+eqR0HfOetur4tgnC8ftU5imRnhi4te+BadWS95c5AM= +github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= +github.com/chzyer/test v0.0.0-20210722231415-061457976a23 h1:dZ0/VyGgQdVGAss6Ju0dt5P0QltE0SFY5Woh6hbIfiQ= +github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=