hashutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MD5

func MD5(bytes []byte) (hash string)

MD5 calculate the hash value of the bytes

func MD5FromFile

func MD5FromFile(file io.Reader) (hash string, err error)

MD5FromFile calculate the hash value of the file If you reuse the file reader, please set its offset to start position first, like os.File.Seek

func MD5FromFileChunk

func MD5FromFileChunk(path string, offset int64, chunkSize int64) (hash string, err error)

MD5FromFileChunk calculate the hash value of the file chunk

func MD5FromFileName

func MD5FromFileName(path string) (hash string, err error)

MD5FromFileName calculate the hash value of the file

func MD5FromString

func MD5FromString(s string) (hash string)

MD5FromString calculate the hash value of the string

Types

type HashValue added in v0.4.0

type HashValue struct {
	// Offset the file data to calculate the hash value from zero to offset
	Offset int64 `json:"offset"`
	// Hash the file checkpoint hash value
	Hash string `json:"hash"`
}

HashValue the file hash info

func CompareHashValuesWithFileName added in v0.4.0

func CompareHashValuesWithFileName(path string, chunkSize int64, hvs HashValues) (*HashValue, error)

CompareHashValuesWithFileName calculate the file hashes and return the last continuous hit HashValue. The offset in the HashValues must equal chunkSize * N, and N greater than zero

func NewHashValue added in v0.4.0

func NewHashValue(offset int64, hash string) *HashValue

NewHashValue returns an instance of HashValue

type HashValues added in v0.4.0

type HashValues []*HashValue

HashValues the list of *HashValue

func CheckpointsMD5FromFile added in v0.4.0

func CheckpointsMD5FromFile(f *os.File, chunkSize int64, checkpointCount int) (hvs HashValues, err error)

CheckpointsMD5FromFile calculate the hash value of the entire file and first chunk and some checkpoints

func CheckpointsMD5FromFileName added in v0.4.0

func CheckpointsMD5FromFileName(path string, chunkSize int64, checkpointCount int) (hvs HashValues, err error)

CheckpointsMD5FromFileName calculate the hash value of the entire file and first chunk and some checkpoints the first chunk hash is optional the checkpoint hash is optional the entire file hash is required

func (HashValues) Last added in v0.4.0

func (hvs HashValues) Last() *HashValue

Last returns the last element of HashValues

Jump to

Keyboard shortcuts

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