summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/goaes/commands/commands.go5
-rw-r--r--cmd/goaes/commands/decrypt.go4
-rw-r--r--cmd/goaes/commands/encrypt.go4
3 files changed, 10 insertions, 3 deletions
diff --git a/cmd/goaes/commands/commands.go b/cmd/goaes/commands/commands.go
index f7086a9..2a6f51e 100644
--- a/cmd/goaes/commands/commands.go
+++ b/cmd/goaes/commands/commands.go
@@ -1,3 +1,6 @@
package commands
-const fileMode = 0600
+const (
+ fileMode = 0600
+ PassphraseEnvVar = "GOAES_PASSPHRASE"
+)
diff --git a/cmd/goaes/commands/decrypt.go b/cmd/goaes/commands/decrypt.go
index a590f47..9168a00 100644
--- a/cmd/goaes/commands/decrypt.go
+++ b/cmd/goaes/commands/decrypt.go
@@ -36,7 +36,9 @@ func Decrypt(ctx context.Context, cmd *cli.Command) error {
return err
}
- plaintext, err := internal.Decrypt(encryptedPayload.DEK, encryptedPayload.Payload, encryptedPayload.Salt)
+ passphrase := os.Getenv(PassphraseEnvVar)
+
+ plaintext, err := internal.Decrypt(passphrase, encryptedPayload.DEK, encryptedPayload.Payload, encryptedPayload.Salt)
if err != nil {
return err
}
diff --git a/cmd/goaes/commands/encrypt.go b/cmd/goaes/commands/encrypt.go
index b50ef97..df707cb 100644
--- a/cmd/goaes/commands/encrypt.go
+++ b/cmd/goaes/commands/encrypt.go
@@ -21,7 +21,9 @@ func Encrypt(ctx context.Context, cmd *cli.Command) error {
return err
}
- payload, err := internal.Encrypt(plaintext)
+ passphrase := os.Getenv(PassphraseEnvVar)
+
+ payload, err := internal.Encrypt(passphrase, plaintext)
if err != nil {
return err
}