Help us shape the future of Go! Take the 2026 Go Developer Survey

hash

package
v0.1.87 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

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

func Uint64ArrayToBytes

func Uint64ArrayToBytes(arr [4]uint64) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL