A native implementation of the excellent XXHash hashing algorithm.

OneOfOne 85d5025fe1 add NewHash{32,64}. 1 week ago
.vscode 5d931d4a2d more clean up based on recent git changes 3 years ago
benchmarks afb72b2696 go.mod cleanup 10 months ago
cmd 8f0be54a8d add -trimpath to build script 2 months ago
.gitignore 64d24dc3f1 stuff 2 years ago
.travis.yml afb72b2696 go.mod cleanup 10 months ago
LICENSE c775779814 license 3 years ago
README.md 6def279d2c vgo 1 year ago
bugs_test.go 8e3f99d948 nuke the cgo version 3 years ago
go.mod afb72b2696 go.mod cleanup 10 months ago
xxhash.go 85d5025fe1 add NewHash{32,64}. 1 week ago
xxhash_go17.go 84bd68eb03 update travis 1 year ago
xxhash_safe.go 456a93f5df Use the safe version for s390x 11 months ago
xxhash_test.go 4e9e81466d Revert "lint" 2 years ago
xxhash_unsafe.go a70bd9b947 workaround go 1.14's checkptr 2 months ago


xxhash GoDoc Build Status Coverage

This is a native Go implementation of the excellent xxhash* algorithm, an extremely fast non-cryptographic Hash algorithm, working at speeds close to RAM limits.

  • The C implementation is (Copyright (c) 2012-2014, Yann Collet)


go get github.com/OneOfOne/xxhash


  • On Go 1.7+ the pure go version is faster than CGO for all inputs.
  • Supports ChecksumString{32,64} xxhash{32,64}.WriteString, which uses no copies when it can, falls back to copy on appengine.
  • The native version falls back to a less optimized version on appengine due to the lack of unsafe.
  • Almost as fast as the mostly pure assembly version written by the brilliant cespare, while also supporting seeds.
  • To manually toggle the appengine version build with -tags safe.


Core i7-4790 @ 3.60GHz, Linux 4.12.6-1-ARCH (64bit), Go tip (+ff90f4af66 2017-08-19)

➤ go test -bench '64' -count 5 -tags cespare | benchstat /dev/stdin
name                          time/op

# https://github.com/cespare/xxhash
XXSum64Cespare/Func-8          160ns ± 2%
XXSum64Cespare/Struct-8        173ns ± 1%
XXSum64ShortCespare/Func-8    6.78ns ± 1%
XXSum64ShortCespare/Struct-8  19.6ns ± 2%

# this package (default mode, using unsafe)
XXSum64/Func-8                 170ns ± 1%
XXSum64/Struct-8               182ns ± 1%
XXSum64Short/Func-8           13.5ns ± 3%
XXSum64Short/Struct-8         20.4ns ± 0%

# this package (appengine, *not* using unsafe)
XXSum64/Func-8                 241ns ± 5%
XXSum64/Struct-8               243ns ± 6%
XXSum64Short/Func-8           15.2ns ± 2%
XXSum64Short/Struct-8         23.7ns ± 5%

CRC64ISO-8                    1.23µs ± 1%
CRC64ISOString-8              2.71µs ± 4%
CRC64ISOShort-8               22.2ns ± 3%

Fnv64-8                       2.34µs ± 1%
Fnv64Short-8                  74.7ns ± 8%


	h := xxhash.New64()
	// r, err := os.Open("......")
	// defer f.Close()
	r := strings.NewReader(F)
	io.Copy(h, r)
	fmt.Println("xxhash.Backend:", xxhash.Backend)
	fmt.Println("File checksum:", h.Sum64())



  • Rewrite the 32bit version to be more optimized.
  • General cleanup as the Go inliner gets smarter.


This project is released under the Apache v2. licence. See LICENCE for more details.