hash

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package hash provides general hash functions.

Index

Constants

View Source
const (
	ADLER32      = "adler32"
	AVERAGE      = "average"
	BLAKE2S256   = "blake2s-256"
	BLAKE2B256   = "blake2b-256"
	BLAKE2B384   = "blake2b-384"
	BLAKE2B512   = "blake2b-512"
	BLAKE3256    = "blake3-256"
	BLAKE3512    = "blake3-512"
	BLOCKMEAN    = "blockmean"
	BSD          = "bsd"
	CRC16CCITT   = "crc16-ccitt"
	CRC32C       = "crc32-c"
	CRC32K       = "crc32-k"
	CRC32IEEE    = "crc32-ieee"
	CRC64ECMA    = "crc64-ecma"
	CRC64ISO     = "crc64-iso"
	DIFFERENCE   = "difference"
	DJB2         = "djb2"
	ELF          = "elf"
	FLETCHER4    = "fletcher4"
	FNV1         = "fnv-1"
	FNV1A        = "fnv-1a"
	GOST2012256  = "gost-256"
	GOST2012512  = "gost-512"
	HAS160       = "has-160"
	IMPFUZZY     = "impfuzzy"
	IMPHASHO     = "imphasho"
	IMPHASHS     = "imphashs"
	LM           = "lm"
	LSH256       = "lsh-256"
	LSH512       = "lsh-512"
	LUHN         = "luhn"
	MARRHILDRETH = "marrhildreth"
	MD2          = "md2"
	MD4          = "md4"
	MD5          = "md5"
	MD6          = "md6"
	MEDIAN       = "median"
	MURMUR3      = "murmur3"
	NT           = "nt"
	PDQ          = "pdq"
	PE           = "pe"
	PHASH        = "phash"
	RAPIDHASH    = "rapidhash"
	RASH         = "rash"
	RIPEMD160    = "ripemd-160"
	SDHASH       = "sdhash"
	SHA1         = "sha1"
	SHA224       = "sha224"
	SHA256       = "sha256"
	SHA512       = "sha512"
	SHA3224      = "sha3-224"
	SHA3256      = "sha3-256"
	SHA3384      = "sha3-384"
	SHA3512      = "sha3-512"
	SHAKE128     = "shake128"
	SHAKE256     = "shake256"
	SIPHASH      = "siphash"
	SKEIN224     = "skein-224"
	SKEIN256     = "skein-256"
	SKEIN384     = "skein-384"
	SKEIN512     = "skein-512"
	SM3          = "sm3"
	SSDEEP       = "ssdeep"
	STREEBOG256  = "streebog-256"
	STREEBOG512  = "streebog-512"
	SYSV         = "sysv"
	TLSH         = "tlsh"
	WHASH        = "whash"
	WHIRLPOOL    = "whirlpool"
	XXH3         = "xxh3"
	XXH32        = "xxh32"
	XXH64        = "xxh64"
)

Variables

View Source
var Algorithms = []struct {
	Name string
	Type Type
}{
	{ADLER32, Checksum},
	{AVERAGE, Perceptual},
	{BLAKE2S256, Cryptographic},
	{BLAKE2B256, Cryptographic},
	{BLAKE2B384, Cryptographic},
	{BLAKE2B512, Cryptographic},
	{BLAKE3256, Cryptographic},
	{BLAKE3512, Cryptographic},
	{BLOCKMEAN, Perceptual},
	{BSD, Unix},
	{CRC16CCITT, Checksum},
	{CRC32C, Checksum},
	{CRC32K, Checksum},
	{CRC32IEEE, Checksum},
	{CRC64ECMA, Checksum},
	{CRC64ISO, Checksum},
	{DIFFERENCE, Perceptual},
	{DJB2, Performance},
	{ELF, Unix},
	{FLETCHER4, Checksum},
	{FNV1, Performance},
	{FNV1A, Performance},
	{GOST2012256, Cryptographic},
	{GOST2012512, Cryptographic},
	{HAS160, Cryptographic},
	{IMPFUZZY, Similarity},
	{IMPHASHO, Similarity},
	{IMPHASHS, Similarity},
	{LM, Windows},
	{LSH256, Cryptographic},
	{LSH512, Cryptographic},
	{LUHN, Checksum},
	{MARRHILDRETH, Perceptual},
	{MD2, Cryptographic},
	{MD4, Cryptographic},
	{MD5, Cryptographic},
	{MD6, Cryptographic},
	{MEDIAN, Perceptual},
	{MURMUR3, Performance},
	{NT, Windows},
	{PDQ, Perceptual},
	{PE, Windows},
	{PHASH, Perceptual},
	{RAPIDHASH, Performance},
	{RASH, Perceptual},
	{RIPEMD160, Cryptographic},
	{SDHASH, Similarity},
	{SHA1, Cryptographic},
	{SHA256, Cryptographic},
	{SHA512, Cryptographic},
	{SHA3224, Cryptographic},
	{SHA3256, Cryptographic},
	{SHA3384, Cryptographic},
	{SHA3512, Cryptographic},
	{SHAKE128, Cryptographic},
	{SHAKE256, Cryptographic},
	{SIPHASH, Performance},
	{SKEIN224, Cryptographic},
	{SKEIN256, Cryptographic},
	{SKEIN384, Cryptographic},
	{SKEIN512, Cryptographic},
	{SM3, Cryptographic},
	{SSDEEP, Similarity},
	{STREEBOG256, Cryptographic},
	{STREEBOG512, Cryptographic},
	{SYSV, Unix},
	{TLSH, Similarity},
	{WHASH, Perceptual},
	{WHIRLPOOL, Cryptographic},
	{XXH3, Performance},
	{XXH32, Performance},
	{XXH64, Performance},
}

Algorithms supported

View Source
var ErrNotSupported = errors.New("algorithm not supported")

ErrNotSupported if algorithm is implemented

Functions

func IsSupported added in v1.1.0

func IsSupported(algo string) bool

IsSupported returns if the algorithm is implemented

func MustSum

func MustSum(algo string, data []byte) string

MustSum returns only the hash sum.

func Sum

func Sum(algo string, data []byte) (string, error)

Sum returns the hash sum and any errors.

Types

type Type

type Type int
const (
	Cryptographic Type = iota
	Performance
	Perceptual
	Similarity
	Checksum
	Windows
	Unix
)

Jump to

Keyboard shortcuts

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