Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

Add support for the password flag to the decrypt command

Alba Rincóne791b4030923
diff --git a/cli/cmd/authenticator.go b/cli/cmd/authenticator.go
index 7f72adf29d..7e6ca100c3 100644
--- a/cli/cmd/authenticator.go
+++ b/cli/cmd/authenticator.go
@@ -19,11 +19,16 @@ var decryptExportCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
inputPath := args[0]
outputPath := args[1]
- return authenticator.DecryptExport(inputPath, outputPath)
+
+ password, _ := cmd.Flags().GetString("password")
+
+ return authenticator.DecryptExport(inputPath, outputPath, password)
},
}
func init() {
+ decryptExportCmd.Flags().StringP("password", "p", "", "Password for decryption")
+
rootCmd.AddCommand(authenticatorCmd)
authenticatorCmd.AddCommand(decryptExportCmd)
}
diff --git a/cli/pkg/authenticator/decrypt.go b/cli/pkg/authenticator/decrypt.go
index f841de2717..c19e1dbbc7 100644
--- a/cli/pkg/authenticator/decrypt.go
+++ b/cli/pkg/authenticator/decrypt.go
@@ -21,7 +21,7 @@ type _KDF struct {
Salt string `json:"salt"`
}
-func DecryptExport(inputPath string, outputPath string) error {
+func DecryptExport(inputPath string, outputPath string, password string) error {
exportFile, err := internal.ResolvePath(inputPath)
if err != nil {
return fmt.Errorf("error resolving exportFile path (in): %v", err)
@@ -45,10 +45,13 @@ func DecryptExport(inputPath string, outputPath string) error {
return fmt.Errorf("unsupported export version: %d", export.Version)
}
- password, err := internal.GetSensitiveField("Enter password to decrypt export")
- if err != nil {
- return err
+ if password == "" {
+ password, err = internal.GetSensitiveField("Enter password to decrypt export")
+ if err != nil {
+ return err
+ }
}
+
fmt.Printf("\n....")
key, err := eCrypto.DeriveArgonKey(password, export.KDFParams.Salt, export.KDFParams.MemLimit, export.KDFParams.OpsLimit)
if err != nil {