hash

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BufferSize = 4096 // BufferSize is the size of the buffer used for reading files.
)

Variables

This section is empty.

Functions

func ComputeHashList

func ComputeHashList() []string

ComputeHashList returns a list of all available hash types.

Types

type Blake added in v1.0.3

type Blake struct {
	Blake2b256 string `json:"blake2b256"`
	Blake2b384 string `json:"blake2b384"`
	Blake2b512 string `json:"blake2b512"`
	Blake2s256 string `json:"blake2s256"`
}

type CRC

type CRC struct {
	CRC32IEEE       string `json:"crc32_IEEE"`
	CRC32Koopman    string `json:"crc32_Koopman"`
	CRC32Castagnoli string `json:"crc32_Castagnoli"`
	CRC64IOS        string `json:"crc64_ISO"`
	CRC64ECMA       string `json:"crc64_ECMA"`
}

type FNV

type FNV struct {
	FNV32  string `json:"fnv32"`
	FNV32a string `json:"fnv32a"`
	FNV64  string `json:"fnv64"`
	FNV64a string `json:"fnv64a"`
}

type GenericHash

type GenericHash struct {
	Input       []byte `json:"input"`
	HashBytes   []byte `json:"hashBytes"`
	HexDigest   string `json:"hexDigest"`
	Duration    int64  `json:"duration"`
	DurationStr string `json:"durationStr"`
}

GenericHash represents a hash of data.

func ComputeHash

func ComputeHash(data []byte, hashType string, file bool) (*GenericHash, error)

ComputeHash returns a hash of the data using the specified hash type.

func Hash

func Hash(data []byte, hash hash.Hash) *GenericHash

Hash returns a hash of the data using the specified hash type.

func HashFile

func HashFile(path string, hash hash.Hash) (*GenericHash, error)

HashFile returns a hash of the file using the specified hash type.

type HasherArray

type HasherArray struct {
	Type string `json:"type"`
	Hash string `json:"hash"`
}

type Hashes

type Hashes struct {
	Adler32     string `json:"adler32"`
	MD4         string `json:"md4"`
	MD5         string `json:"md5"`
	SHA1        string `json:"sha1"`
	SHA2        SHA2   `json:"sha2"`
	SHA3        SHA3   `json:"sha3"`
	FNV         FNV    `json:"fnv"`
	CRC         CRC    `json:"crc"`
	Blake       Blake  `json:"blake"`
	Duration    int64  `json:"duration"`
	DurationStr string `json:"durationStr"`
}

func HasherMulti

func HasherMulti(b []byte) (Hashes, error)

func HasherMultiFile

func HasherMultiFile(path string) (Hashes, error)

func (Hashes) Array

func (h Hashes) Array() []HasherArray

type SHA2

type SHA2 struct {
	SHA224     string `json:"sha224"`
	SHA256     string `json:"sha256"`
	SHA384     string `json:"sha384"`
	SHA512     string `json:"sha512"`
	SHA512_224 string `json:"sha512_224"`
	SHA512_256 string `json:"sha512_256"`
}

type SHA3

type SHA3 struct {
	SHA256   string `json:"sha3_256"`
	SHA512   string `json:"sha3_512"`
	Shake128 string `json:"shake128"`
	Shake256 string `json:"shake256"`
}

Jump to

Keyboard shortcuts

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