Crypto and input management packages.

This commit is contained in:
Mariano Uvalle 2023-11-02 07:09:51 +00:00
parent f0867a1063
commit b8a4ad02d7
5 changed files with 163 additions and 0 deletions

17
pkg/input/password.go Normal file
View 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)
}