hashing

package
v1.62.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package hashing provides utilities for calculating hashes.

Index

Constants

View Source
const (
	HashMd5       = "MD5"
	HashSha256    = "SHA256"
	HashSha1      = "SHA1"
	HashMurmur    = "Murmur"
	HashXXHash    = "xxhash"     // https://github.com/OneOfOne/xxhash
	HashBlake2256 = "blake2b256" // https://www.blake2.net/
)

Variables

This section is empty.

Functions

func CalculateHash

func CalculateHash(text, htype string) string

CalculateHash calculates the hash of some text using the requested htype hashing algorithm.

func CalculateMD5Hash

func CalculateMD5Hash(text string) string

func CalculateStringHash added in v1.42.0

func CalculateStringHash(hashingAlgo IHash, text string) string

CalculateStringHash returns the hash of some text using a particular hashing algorithm

func HasLikelyHexHashStringEntropy added in v1.17.1

func HasLikelyHexHashStringEntropy(str string) bool

HasLikelyHexHashStringEntropy states whether a string has an entropy which may entail it is a hexadecimal hash This is based on the work done by `detect-secrets` https://github.com/Yelp/detect-secrets/blob/2fc0e31f067af98d97ad0f507dac032c9506f667/detect_secrets/plugins/high_entropy_strings.py#L150

func IsLikelyHexHashString added in v1.17.1

func IsLikelyHexHashString(str string) bool

IsLikelyHexHashString determines whether the string is likely to be a hexadecimal hash or not.

Types

type IHash

type IHash interface {
	Calculate(reader io.Reader) (string, error)
	CalculateWithContext(ctx context.Context, reader io.Reader) (string, error)
	GetType() string
}

IHash defines a hashing algorithm.

func NewBespokeHashingAlgorithm added in v1.42.0

func NewBespokeHashingAlgorithm(algorithm hash.Hash) (IHash, error)

NewBespokeHashingAlgorithm defines a bespoke hashing algorithm

func NewHashingAlgorithm

func NewHashingAlgorithm(htype string) (IHash, error)

Jump to

Keyboard shortcuts

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