hashx

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash32Bytes

func Hash32Bytes(data []byte, h hash.Hash32) uint32

Hash32Bytes calculate 32 bit hash as uint result for byte array data.

Usage: Hash32Bytes(data, md5.New())

func Hash32File

func Hash32File(path string, h hash.Hash32) (uint32, error)

Hash32Reader calculate 32 bit hash as uint result for byte array data. The file is closed when hash calculating finish or an err occurred. If error occurred when read data, return 0 as result and a an error.

Usage: Hash32File(file, md5.New())

func Hash32Reader

func Hash32Reader(r io.Reader, h hash.Hash32) (uint32, error)

Hash32Reader calculate 32 bit hash as uint result for byte array data. If error occurred when read data, return 0 as result and a an error.

Usage: Hash32Reader(r, md5.New())

func Hash64Bytes

func Hash64Bytes(data []byte, h hash.Hash64) uint64

Hash64Bytes calculate 64 bit hash as uint result for byte array data.

func Hash64File

func Hash64File(path string, h hash.Hash64) (uint64, error)

Hash64Reader calculate 64 bit hash as uint result for byte array data. The file is closed when hash calculating finish or an err occurred. If error occurred when read data, return 0 as result and a an error.

func Hash64Reader

func Hash64Reader(r io.Reader, h hash.Hash64) (uint64, error)

Hash64Reader calculate 64 bit hash as uint result for byte array data. If error occurred when read data, return 0 as result and a an error.

Types

type HashResult

type HashResult []byte

HashResult hold hash results

func HashBytes

func HashBytes(data []byte, h hash.Hash) HashResult

HashBytes calculate hash for byte array data.

Usage: HashBytes(data, md5.New()), HashBytes(data, sha256.New())

func HashFile

func HashFile(path string, h hash.Hash) (HashResult, error)

HashFile calculate hash for a file. The file is closed when hash calculating finish or an err occurred. If error occurred when read data, return nil result and a an error.

Usage: HashFile(file, md5.New()), HashFile(file, sha256.New())

func HashReader

func HashReader(r io.Reader, h hash.Hash) (HashResult, error)

HashReader calculate hash for all data from reader. If error occurred when read data, return nil result and a an error.

Usage: HashReader(r, md5.New()), HashReader(r, sha256.New())

func (HashResult) Data

func (r HashResult) Data() []byte

Data return hash result as binary data.

func (HashResult) ToHex

func (r HashResult) ToHex() string

ToHex return hash result data as lower case hexed string

func (HashResult) ToHexUpper

func (r HashResult) ToHexUpper() string

ToHexUpper return hash result data as upper case hexed string

Jump to

Keyboard shortcuts

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