mirror of
https://github.com/FiloSottile/age.git
synced 2026-01-06 04:04:50 +00:00
@@ -148,7 +148,7 @@ func main() {
|
||||
case decryptFlag:
|
||||
decrypt(identityFlags, in, out)
|
||||
case passFlag:
|
||||
pass, err := passphrasePromptWithDefault()
|
||||
pass, err := passphrasePromptForEncryption()
|
||||
if err != nil {
|
||||
logFatalf("Error: %v", err)
|
||||
}
|
||||
@@ -158,7 +158,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func passphrasePromptWithDefault() (string, error) {
|
||||
func passphrasePromptForEncryption() (string, error) {
|
||||
fmt.Fprintf(os.Stderr, "Enter passphrase (leave empty to autogenerate a secure one): ")
|
||||
pass, err := readPassphrase()
|
||||
if err != nil {
|
||||
@@ -172,6 +172,15 @@ func passphrasePromptWithDefault() (string, error) {
|
||||
}
|
||||
p = strings.Join(words, "-")
|
||||
fmt.Fprintf(os.Stderr, "Using the autogenerated passphrase %q.\n", p)
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "Confirm passphrase: ")
|
||||
confirm, err := readPassphrase()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not read passphrase: %v", err)
|
||||
}
|
||||
if string(confirm) != p {
|
||||
return "", fmt.Errorf("passphrases didn't match")
|
||||
}
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user