Skip to content

Commit

Permalink
Add KeyHasher based on CRC-32
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Renström committed Sep 5, 2015
1 parent 276e8ae commit d4875ab
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions crc32.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package jump

import "hash"

type crc32Hasher struct {
crc32 hash.Hash32
}

func (h *crc32Hasher) Write(p []byte) (n int, err error) {
return h.crc32.Write(p)
}

func (h *crc32Hasher) Sum(b []byte) []byte {
return h.crc32.Sum(b)
}

func (h *crc32Hasher) Reset() {
h.crc32.Reset()
}

func (h *crc32Hasher) Size() int {
return h.crc32.Size()
}

func (h *crc32Hasher) BlockSize() int {
return h.crc32.BlockSize()
}

func (h *crc32Hasher) Sum32() uint32 {
return h.crc32.Sum32()
}

func (h *crc32Hasher) Sum64() uint64 {
return uint64(h.crc32.Sum32())
}

var _ hash.Hash32 = (*crc32Hasher)(nil)
var _ hash.Hash64 = (*crc32Hasher)(nil)

0 comments on commit d4875ab

Please sign in to comment.