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