You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
391 B
22 lines
391 B
6 years ago
|
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
|
||
|
}
|