Documentation
¶
Overview ¶
Package rhash provides implementations of rolling-hash functions.
A rolling-hash is a hash function that "remembers" only the last n bytes it received, where n is a parameter. Meaning, the hash of a byte sequence always equals the hash of its last n bytes.
Index ¶
- func RabinFingerprintSum32(data []byte) uint32
- func RabinFingerprintSum64(data []byte) uint64
- type Buz32
- type Buz64
- type RabinFingerprint32
- func (h *RabinFingerprint32) BlockSize() int
- func (h *RabinFingerprint32) Reset()
- func (h *RabinFingerprint32) Size() int
- func (h *RabinFingerprint32) Sum(b []byte) []byte
- func (h *RabinFingerprint32) Sum32() uint32
- func (h *RabinFingerprint32) Write(data []byte) (int, error)
- func (h *RabinFingerprint32) WriteByte(b byte) error
- type RabinFingerprint64
- func (h *RabinFingerprint64) BlockSize() int
- func (h *RabinFingerprint64) Reset()
- func (h *RabinFingerprint64) Size() int
- func (h *RabinFingerprint64) Sum(b []byte) []byte
- func (h *RabinFingerprint64) Sum64() uint64
- func (h *RabinFingerprint64) Write(data []byte) (int, error)
- func (h *RabinFingerprint64) WriteByte(b byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RabinFingerprintSum32 ¶
RabinFingerprintSum32 returns the Rabin fingerprint of data.
func RabinFingerprintSum64 ¶
RabinFingerprintSum64 returns the Rabin fingerprint of data.
Types ¶
type Buz32 ¶
type Buz32 struct {
// contains filtered or unexported fields
}
Buz32 implements a buzhash rolling-hash. Implements hash.Hash32.
type Buz64 ¶
type Buz64 struct {
// contains filtered or unexported fields
}
Buz64 implements a buzhash rolling-hash. Implements hash.Hash64.
type RabinFingerprint32 ¶
type RabinFingerprint32 struct {
// contains filtered or unexported fields
}
RabinFingerprint32 implements a Rabin fingerprint rolling-hash. Implements hash.Hash32.
func NewRabinFingerprint32 ¶
func NewRabinFingerprint32(n int) *RabinFingerprint32
NewRabinFingerprint32 returns a new rolling hash with a window size of n.
func (*RabinFingerprint32) BlockSize ¶
func (h *RabinFingerprint32) BlockSize() int
BlockSize returns the hash's block size, which is one.
func (*RabinFingerprint32) Reset ¶
func (h *RabinFingerprint32) Reset()
Reset resets the hash to its initial state.
func (*RabinFingerprint32) Size ¶
func (h *RabinFingerprint32) Size() int
Size returns the number of bytes Sum will return, which is four.
func (*RabinFingerprint32) Sum ¶
func (h *RabinFingerprint32) Sum(b []byte) []byte
Sum appends the current hash to b and returns the resulting slice.
func (*RabinFingerprint32) Sum32 ¶
func (h *RabinFingerprint32) Sum32() uint32
Sum32 returns the current hash.
func (*RabinFingerprint32) Write ¶
func (h *RabinFingerprint32) Write(data []byte) (int, error)
Write updates the hash with the given bytes. Always returns len(data), nil.
func (*RabinFingerprint32) WriteByte ¶
func (h *RabinFingerprint32) WriteByte(b byte) error
WriteByte updates the hash with the given byte. Always returns nil.
type RabinFingerprint64 ¶
type RabinFingerprint64 struct {
// contains filtered or unexported fields
}
RabinFingerprint64 implements a Rabin fingerprint rolling-hash. Implements hash.Hash64.
func NewRabinFingerprint64 ¶
func NewRabinFingerprint64(n int) *RabinFingerprint64
NewRabinFingerprint64 returns a new rolling hash with a window size of n.
func (*RabinFingerprint64) BlockSize ¶
func (h *RabinFingerprint64) BlockSize() int
BlockSize returns the hash's block size, which is one.
func (*RabinFingerprint64) Reset ¶
func (h *RabinFingerprint64) Reset()
Reset resets the hash to its initial state.
func (*RabinFingerprint64) Size ¶
func (h *RabinFingerprint64) Size() int
Size returns the number of bytes Sum will return, which is eight.
func (*RabinFingerprint64) Sum ¶
func (h *RabinFingerprint64) Sum(b []byte) []byte
Sum appends the current hash to b and returns the resulting slice.
func (*RabinFingerprint64) Sum64 ¶
func (h *RabinFingerprint64) Sum64() uint64
Sum64 returns the current hash.
func (*RabinFingerprint64) Write ¶
func (h *RabinFingerprint64) Write(data []byte) (int, error)
Write updates the hash with the given bytes. Always returns len(data), nil.
func (*RabinFingerprint64) WriteByte ¶
func (h *RabinFingerprint64) WriteByte(b byte) error
WriteByte updates the hash with the given byte. Always returns nil.