mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-07-27 10:20:28 +00:00
29 lines
484 B
Go
29 lines
484 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/filebrowser/filebrowser/v2/users"
|
|
)
|
|
|
|
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),
|
|
RunE: func(_ *cobra.Command, args []string) error {
|
|
pwd, err := users.HashPwd(args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(pwd)
|
|
return nil
|
|
},
|
|
}
|