Documentation
¶
Index ¶
- Constants
- func Hash(bytes []byte) (hash string)
- func HashFromFile(file io.Reader) (hash string, err error)
- func HashFromFileChunk(path string, offset int64, chunkSize int64) (hash string, err error)
- func HashFromFileName(path string) (hash string, err error)
- func HashFromString(s string) (hash string)
- func InitDefaultHash(algorithm string) error
- func New() hash.Hash
- type HashValue
- type HashValues
Constants ¶
const ( // DefaultHash the default hash algorithm DefaultHash = MD5Hash // MD5Hash the MD5 hash algorithm MD5Hash = "md5" // SHA1Hash the SHA-1 hash algorithm SHA1Hash = "sha1" // SHA256Hash the SHA256 hash algorithm SHA256Hash = "sha256" // SHA512Hash the SHA-512 hash algorithm SHA512Hash = "sha512" // CRC32Hash the CRC-32 checksum CRC32Hash = "crc32" // CRC64Hash the CRC-64 checksum CRC64Hash = "crc64" // Adler32Hash the Adler-32 checksum Adler32Hash = "adler32" // FNV132Hash the 32-bit FNV-1 non-cryptographic hash function FNV132Hash = "fnv-1-32" // FNV1A32Hash the 32-bit FNV-1a non-cryptographic hash function FNV1A32Hash = "fnv-1a-32" // FNV164Hash the 64-bit FNV-1 non-cryptographic hash function FNV164Hash = "fnv-1-64" // FNV1A64Hash the 64-bit FNV-1a non-cryptographic hash function FNV1A64Hash = "fnv-1a-64" // FNV1128Hash the 128-bit FNV-1 non-cryptographic hash function FNV1128Hash = "fnv-1-128" // FNV1A128Hash the 128-bit FNV-1a non-cryptographic hash function FNV1A128Hash = "fnv-1a-128" )
Variables ¶
This section is empty.
Functions ¶
func HashFromFile ¶ added in v0.4.2
HashFromFile 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 HashFromFileChunk ¶ added in v0.4.2
HashFromFileChunk calculate the hash value of the file chunk
func HashFromFileName ¶ added in v0.4.2
HashFromFileName calculate the hash value of the file
func HashFromString ¶ added in v0.4.2
HashFromString calculate the hash value of the string
func InitDefaultHash ¶ added in v0.4.2
InitDefaultHash initial default hash factory
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) (eq *HashValue, err 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 CheckpointsHashFromFile ¶ added in v0.4.2
func CheckpointsHashFromFile(f *os.File, chunkSize int64, checkpointCount int) (hvs HashValues, err error)
CheckpointsHashFromFile calculate the hash value of the entire file and first chunk and some checkpoints
func CheckpointsHashFromFileName ¶ added in v0.4.2
func CheckpointsHashFromFileName(path string, chunkSize int64, checkpointCount int) (hvs HashValues, err error)
CheckpointsHashFromFileName 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