all repos — honk @ b237cfa543fcdbc9ef30ac0e87c60772011f12fe

my fork of honk

use ssh/terminal to read a password without echo.
Ted Unangst tedu@tedunangst.com
Wed, 10 Apr 2019 08:16:29 -0400
commit

b237cfa543fcdbc9ef30ac0e87c60772011f12fe

parent

b09fddf35ff0d6ebf8f145d2d5b30d90fc7da7d6

1 files changed, 7 insertions(+), 6 deletions(-)

jump to
M util.goutil.go

@@ -29,6 +29,7 @@ "os/signal"

"strings" "golang.org/x/crypto/bcrypt" + "golang.org/x/crypto/ssh/terminal" _ "humungus.tedunangst.com/r/go-sqlite3" )

@@ -71,11 +72,11 @@ c := make(chan os.Signal)

signal.Notify(c, os.Interrupt) go func() { <-c - fmt.Printf("\x1b[?12;25h\x1b[0m") fmt.Printf("\n") os.Remove(dbname) os.Exit(1) }() + for _, line := range strings.Split(string(schema), ";") { _, err = db.Exec(line) if err != nil {

@@ -96,14 +97,14 @@ if len(name) < 1 {

log.Print("that's way too short") return } - fmt.Printf("password: \x1b[?25l\x1b[%d;%dm \x1b[16D", 30, 40) - pass, err := r.ReadString('\n') - fmt.Printf("\x1b[0m\x1b[?12;25h") + fmt.Printf("password: ") + passbytes, err := terminal.ReadPassword(1) + fmt.Printf("\n") if err != nil { - log.Fatal(err) + log.Print(err) return } - pass = pass[:len(pass)-1] + pass := string(passbytes) if len(pass) < 6 { log.Print("that's way too short") return