diff options
Diffstat (limited to 'tools/hashpw')
| -rw-r--r-- | tools/hashpw/hashpw.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/hashpw/hashpw.go b/tools/hashpw/hashpw.go index 526ad15..f1e76db 100644 --- a/tools/hashpw/hashpw.go +++ b/tools/hashpw/hashpw.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "crypto/rand" "encoding/base64" "fmt" @@ -18,6 +19,15 @@ func hashpw() error { if err != nil { return err } + fmt.Fprint(os.Stderr, "Confirm password: ") + pwConfirm, err := term.ReadPassword(int(os.Stdin.Fd())) + fmt.Fprintln(os.Stderr) + if err != nil { + return err + } + if !bytes.Equal(password, pwConfirm) { + return fmt.Errorf("passwords do not match") + } salt := make([]byte, pwhash.SaltSize) rand.Read(salt) hash, err := pwhash.Hash(string(password), salt) |
