Documentation
¶
Index ¶
- func MD5(bytes []byte) (hash string)
- func MD5FromFile(file io.Reader) (hash string, err error)
- func MD5FromFileChunk(path string, offset int64, chunkSize int64) (hash string, err error)
- func MD5FromFileName(path string) (hash string, err error)
- func MD5FromString(s string) (hash string)
- type HashValue
- type HashValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MD5FromFile ¶
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 ¶
MD5FromFileChunk calculate the hash value of the file chunk
func MD5FromFileName ¶
MD5FromFileName calculate the hash value of the file
func MD5FromString ¶
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
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