mirror of https://github.com/chzyer/readline.git
add go.mod and remove unnecessary dep
This commit is contained in:
parent
2972be24d4
commit
a11d8f26cf
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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=
|
Loading…
Reference in New Issue