Skip to content

Commit ffac587

Browse files
authored
Merge pull request #3 from vjagaro/suppress-password-output
Suppress password output
2 parents a018cf1 + fe69b34 commit ffac587

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ require (
1111
github.com/aead/argon2 v0.0.0-20180111183520-a87724528b07 // indirect
1212
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
1313
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
14+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
1415
)

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
1818
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1919
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
2020
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
21+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
2122
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
2223
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2324
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import (
55
"bytes"
66
"encoding/json"
77
"fmt"
8+
"golang.org/x/term"
89
"os"
10+
"syscall"
911
)
1012

1113
func errAndExit(message string, err error) {
@@ -40,15 +42,13 @@ func main() {
4042
errAndExit("Improperly formatted JSON file: %v", err)
4143
}
4244
fmt.Println("Please input your master password")
43-
var reader = bufio.NewReader(os.Stdin)
44-
password, err := reader.ReadBytes('\n')
45+
password, err := term.ReadPassword(syscall.Stdin)
4546
if err != nil {
4647
errAndExit("Failed to read password from input: %v", err)
4748
}
48-
if len(password) < 2 {
49+
if len(password) < 1 {
4950
errAndExit("Empty password", nil)
5051
}
51-
password = password[:len(password)-1]
5252
aegisDb := exported.Decrypt(password)
5353
if len(aegisDb.Entries) == 0 {
5454
errAndExit("No entries in the database, nothing to save", nil)
@@ -57,6 +57,7 @@ func main() {
5757
stat, err := os.Stat(kdbxPath)
5858
if stat != nil || os.IsExist(err) {
5959
fmt.Println("A file already exists at the specified output path. Are sure you want to rewrite it completely? Y/N")
60+
var reader = bufio.NewReader(os.Stdin)
6061
r, _, err := reader.ReadRune()
6162
if err != nil {
6263
errAndExit("Failed to read confirmation from stdin: %v", err)

0 commit comments

Comments
 (0)