mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-12 11:10:35 +00:00
23 lines
464 B
Go
23 lines
464 B
Go
|
//go:build windows
|
||
|
// +build windows
|
||
|
|
||
|
package input
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"syscall"
|
||
|
|
||
|
"golang.org/x/term"
|
||
|
)
|
||
|
|
||
|
// readSecurePassword reads the user's password with prompt.
|
||
|
func readSecurePassword(prompt string) (string, error) {
|
||
|
s, err := term.MakeRaw(int(syscall.Stdin))
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
defer func() { _ = term.Restore(int(syscall.Stdin), s) }()
|
||
|
trm := term.NewTerminal(ReadWriter{os.Stdin, os.Stdout}, prompt)
|
||
|
return trm.ReadPassword(prompt)
|
||
|
}
|