Beispiel #1
0
func createPassPhrase() ([]byte, error) {
	fmt.Fprint(os.Stderr, "Enter passphrase (empty for no passphrase): ")
	pass1, err := terminal.ReadPassword(syscall.Stdin)
	if err != nil {
		return nil, err
	}
	fmt.Fprint(os.Stderr, "\nEnter same passphrase again: ")
	pass2, err := terminal.ReadPassword(syscall.Stdin)
	if err != nil {
		return nil, err
	}
	fmt.Fprintln(os.Stderr)

	if bytes.Compare(pass1, pass2) != 0 {
		return nil, errors.New("Passphrases do not match.")
	}
	return pass1, nil
}
Beispiel #2
0
func askPassPhrase(name string) []byte {
	fmt.Fprintf(os.Stderr, "Enter passphrase for %v (empty for no passphrase): ", name)
	pass, _ := terminal.ReadPassword(syscall.Stdin)
	fmt.Fprintln(os.Stderr)
	return pass
}