55 "bytes"
66 "encoding/json"
77 "fmt"
8+ "golang.org/x/term"
89 "os"
10+ "syscall"
911)
1012
1113func 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