feat: add hash command

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
pull/610/head
Henrique Dias 2019-01-06 17:53:47 +00:00
parent 56c1536693
commit a2742dff16
1 changed files with 24 additions and 0 deletions

24
cmd/hash.go Normal file
View File

@ -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 <password>",
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)
},
}