github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/cli/input/readpass_windows.go (about)

     1  //go:build windows
     2  
     3  package input
     4  
     5  import (
     6  	"os"
     7  	"syscall"
     8  
     9  	"golang.org/x/term"
    10  )
    11  
    12  // readSecurePassword reads the user's password with prompt.
    13  func readSecurePassword(prompt string) (string, error) {
    14  	s, err := term.MakeRaw(int(syscall.Stdin))
    15  	if err != nil {
    16  		return "", err
    17  	}
    18  	defer func() { _ = term.Restore(int(syscall.Stdin), s) }()
    19  	trm := term.NewTerminal(ReadWriter{os.Stdin, os.Stdout}, prompt)
    20  	return trm.ReadPassword(prompt)
    21  }