Skip to content

Commit

Permalink
Permit hands-free passphrase generation
Browse files Browse the repository at this point in the history
  • Loading branch information
n-hebert committed Aug 10, 2022
1 parent e206adb commit 16ff95a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/age/age.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,16 @@ func passphrasePromptForEncryption() (string, error) {
fmt.Fprintln(os.Stderr, "Using passphrase from environment variable.")
return pass, nil
}
pass, err := readSecret("Enter passphrase (leave empty to autogenerate a secure one):")
if err != nil {
return "", fmt.Errorf("could not read passphrase: %v", err)
p := ""
if _, exists := os.LookupEnv("AGE_AUTOGENERATE_PASSPHRASE"); exists {
fmt.Fprintln(os.Stderr, "Skipping request for the user to enter a passphrase.")
} else {
pass, err := readSecret("Enter passphrase (leave empty to autogenerate a secure one):")
if err != nil {
return "", fmt.Errorf("could not read passphrase: %v", err)
}
p = string(pass)
}
p := string(pass)
if p == "" {
var words []string
for i := 0; i < 10; i++ {
Expand Down

0 comments on commit 16ff95a

Please sign in to comment.