Skip to content

Commit

Permalink
Secret key is optional now for encryption
Browse files Browse the repository at this point in the history
Will be autogenerated, if not specified.
  • Loading branch information
dtitov committed Nov 2, 2020
1 parent 70f5f41 commit 202713a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var generateOptionsParser = flags.NewParser(&generateOptions, flags.None)

var encryptOptions struct {
FileName string `short:"f" long:"file" description:"File to encrypt" value-name:"FILE" required:"true"`
SecretKeyFileName string `short:"s" long:"seckey" description:"Secret key to use" value-name:"FILE" required:"true"`
PublicKeyFileName string `short:"p" long:"pubkey" description:"Public key to use" value-name:"FILE" required:"true"`
SecretKeyFileName string `short:"s" long:"seckey" description:"Secret key to use" value-name:"FILE"`
}
var encryptOptionsParser = flags.NewParser(&encryptOptions, flags.None)

Expand Down Expand Up @@ -90,7 +90,13 @@ func main() {
if err != nil {
log.Fatal(aurora.Red(err))
}
privateKey, err := readPrivateKey(encryptOptions.SecretKeyFileName)
var privateKey [32]byte
if encryptOptions.SecretKeyFileName == "" {
promptYesNo("Secret key not specified and will be autogenerated. Do you want to continue?")
_, privateKey, err = keys.GenerateKeyPair()
} else {
privateKey, err = readPrivateKey(encryptOptions.SecretKeyFileName)
}
if err != nil {
log.Fatal(aurora.Red(err))
}
Expand Down

0 comments on commit 202713a

Please sign in to comment.