github.com/prysmaticlabs/prysm@v1.4.4/shared/cmd/password_reader.go (about) 1 package cmd 2 3 import ( 4 "os" 5 6 "golang.org/x/crypto/ssh/terminal" 7 ) 8 9 // PasswordReader reads a password from a mock or stdin. 10 type PasswordReader interface { 11 ReadPassword() (string, error) 12 } 13 14 // StdInPasswordReader reads a password from stdin. 15 type StdInPasswordReader struct { 16 } 17 18 // ReadPassword reads a password from stdin. 19 func (pr StdInPasswordReader) ReadPassword() (string, error) { 20 pwd, err := terminal.ReadPassword(int(os.Stdin.Fd())) 21 return string(pwd), err 22 }