Crypto and input management packages.
This commit is contained in:
parent
f0867a1063
commit
b8a4ad02d7
5 changed files with 163 additions and 0 deletions
17
pkg/input/password.go
Normal file
17
pkg/input/password.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package input
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// ReadPassword reads a single line of text from the terminal withouth echoing it out.
|
||||
func ReadPassword() string {
|
||||
raw, err := term.ReadPassword(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("could not reat password from the terminal: %s", err.Error()))
|
||||
}
|
||||
return string(raw)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue