mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 11:41:48 +00:00
cli: handle passwords securely
This commit is contained in:
parent
e87d21d396
commit
3f98449ce0
3 changed files with 55 additions and 8 deletions
|
@ -49,15 +49,10 @@ func readLine(trm *term.Terminal, prompt string) (string, error) {
|
|||
// ReadPassword reads the user's password with prompt.
|
||||
func ReadPassword(prompt string) (string, error) {
|
||||
trm := Terminal
|
||||
if trm == nil {
|
||||
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)
|
||||
if trm != nil {
|
||||
return trm.ReadPassword(prompt)
|
||||
}
|
||||
return trm.ReadPassword(prompt)
|
||||
return readSecurePassword(prompt)
|
||||
}
|
||||
|
||||
// ConfirmTx asks for a confirmation to send the tx.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue