Files
checksum/hash/xxh.go

33 lines
361 B
Go

package hash
import (
"github.com/cespare/xxhash"
"hash"
)
type (
Xxh64 struct {
d hash.Hash
}
)
func (m *Xxh64) String() string {
return "xxhash64"
}
func (m *Xxh64) Append(data []byte) {
if m.d == nil {
m.d = xxhash.New()
}
m.d.Write(data)
}
func (m *Xxh64) Finish() []byte {
if m.d == nil {
m.d = xxhash.New()
}
return m.d.Sum(nil)
}