Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Go implementation of SipHash-2-4, a fast short-input PRF created by Jean-Philippe Aumasson and Daniel J. Bernstein.

branch: master

Simplify counting of message bytes.

benchmark           old ns/op    new ns/op    delta
BenchmarkFull8            100          100   +0.00%
BenchmarkFull16           120          114   -5.00%
BenchmarkFull40           115          113   -1.74%
BenchmarkFull64           220          214   -2.73%
BenchmarkFull128          220          216   -1.82%
BenchmarkFull1K          2054         2007   -2.29%
BenchmarkFull8K         16102        15581   -3.24%

benchmark            old MB/s     new MB/s  speedup
BenchmarkFull8          79.73        79.41    1.00x
BenchmarkFull16        132.42       139.21    1.05x
BenchmarkFull40        208.42       210.75    1.01x
BenchmarkFull64        290.55       298.00    1.03x
BenchmarkFull128       579.46       592.46    1.02x
BenchmarkFull1K        498.53       510.12    1.02x
BenchmarkFull8K        508.73       525.76    1.03x
latest commit 42ba037e74
Dmitry Chestnykh authored January 25, 2013
Octocat-spinner-32 README Close paretheses in README :) June 21, 2012
Octocat-spinner-32 hash.go More spacing for readability. June 21, 2012
Octocat-spinner-32 siphash.go Simplify counting of message bytes. January 25, 2013
Octocat-spinner-32 siphash_test.go Also test Hash() with reference vectors. June 28, 2012
README
Go implementation of SipHash-2-4, a fast short-input PRF created by
Jean-Philippe Aumasson and Daniel J. Bernstein (http://131002.net/siphash/).

INSTALLATION

    $ go get github.com/dchest/siphash

USAGE

    import "github.com/dchest/siphash"

There are two ways to use this package.
The slower one is to use the standard hash.Hash64 interface:

    h := siphash.New(key)
    h.Write([]byte("Hello"))
    sum := h.Sum(nil) // returns 8-byte []byte

or

    sum64 := h.Sum64() // returns uint64

The faster one is to use Hash() function, which takes two uint64 parts of
16-byte key and a byte slice, and returns uint64 hash:

    sum64 := siphash.Hash(key0, key1, []byte("Hello"))

The keys and output are little-endian.

FUNCTIONS

func Hash(k0, k1 uint64, p []byte) uint64

    Hash returns the 64-bit SipHash-2-4 of the given byte slice with two
    64-bit parts of 128-bit key: k0 and k1.

func New(key []byte) hash.Hash64

    New returns a new hash.Hash64 computing SipHash-2-4 with 16-byte key.


PUBLIC DOMAIN DEDICATION

Written in 2012 by Dmitry Chestnykh.

To the extent possible under law, the author have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
http://creativecommons.org/publicdomain/zero/1.0/
Something went wrong with that request. Please try again.