2019-01-07 01:53:47 +08:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2020-06-01 07:12:36 +08:00
|
|
|
|
|
|
|
"github.com/filebrowser/filebrowser/v2/users"
|
2019-01-07 01:53:47 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(hashCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
var hashCmd = &cobra.Command{
|
2019-02-15 19:54:44 +08:00
|
|
|
Use: "hash <password>",
|
|
|
|
Short: "Hashes a password",
|
|
|
|
Long: `Hashes a password using bcrypt algorithm.`,
|
|
|
|
Args: cobra.ExactArgs(1),
|
2024-04-02 00:24:06 +08:00
|
|
|
Run: func(_ *cobra.Command, args []string) {
|
2019-01-07 01:53:47 +08:00
|
|
|
pwd, err := users.HashPwd(args[0])
|
|
|
|
checkErr(err)
|
|
|
|
fmt.Println(pwd)
|
|
|
|
},
|
|
|
|
}
|