Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var HashCmd = &cobra.Command{ Use: fmt.Sprintf("hash [%s]", strings.Join(supportedHashFunctions, "|")), Short: "Provide common crypto hashing functions.", Long: usage, Run: func(cmd *cobra.Command, args []string) { data, err := getInputData(cmd, args) if err != nil { cmd.PrintErrf("There was an error reading input for hashing: %s", err.Error()) return } h, err := getHash(args[0]) if err != nil { cmd.PrintErrf("There was an error creating the hash function: %s", err.Error()) return } h.Write(data) hashOut := h.Sum(nil) cmd.Println(hex.EncodeToString(hashOut)) }, Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { return fmt.Errorf("expected 1 argument to specify hash function. got %d", len(args)) } for _, v := range supportedHashFunctions { if v == args[0] { return nil } } return fmt.Errorf("the name %s is not recognized. Please use one of the following: %s", args[0], strings.Join(supportedHashFunctions, ",")) }, }
hashCmd represents the hash command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.