diff --git a/cmd/hash.go b/cmd/hash.go new file mode 100644 index 00000000..e92203e4 --- /dev/null +++ b/cmd/hash.go @@ -0,0 +1,24 @@ +package cmd + +import ( + "fmt" + + "github.com/filebrowser/filebrowser/v2/users" + "github.com/spf13/cobra" +) + +func init() { + rootCmd.AddCommand(hashCmd) +} + +var hashCmd = &cobra.Command{ + Use: "hash ", + Short: "Hashes a password", + Long: `Hashes a password using bcrypt algorithm.`, + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + pwd, err := users.HashPwd(args[0]) + checkErr(err) + fmt.Println(pwd) + }, +}