diff --git a/internal/utils/passphrase.go b/internal/utils/passphrase.go new file mode 100644 index 000000000..03206e838 --- /dev/null +++ b/internal/utils/passphrase.go @@ -0,0 +1,21 @@ +package utils + +import ( + "fmt" + "syscall" + + "golang.org/x/crypto/ssh/terminal" +) + +// AskForPassphrase return passphrase using password input +func AskForPassphrase(prompt string) string { + fmt.Printf(prompt) + bytePassword, err := terminal.ReadPassword(int(syscall.Stdin)) + if err != nil { + panic("read password error") + } + password := string(bytePassword) + fmt.Println() + + return password +}