github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/lib/others/siphash/README.md (about) 1 SipHash (Go) 2 ============ 3 4 [](https://travis-ci.org/dchest/siphash) 5 6 Go implementation of SipHash-2-4, a fast short-input PRF created by 7 Jean-Philippe Aumasson and Daniel J. Bernstein (http://131002.net/siphash/). 8 9 10 ## Installation 11 12 $ go get github.com/dchest/siphash 13 14 ## Usage 15 16 import "github.com/dchest/siphash" 17 18 There are two ways to use this package. 19 The slower one is to use the standard hash.Hash64 interface: 20 21 h := siphash.New(key) 22 h.Write([]byte("Hello")) 23 sum := h.Sum(nil) // returns 8-byte []byte 24 25 or 26 27 sum64 := h.Sum64() // returns uint64 28 29 The faster one is to use Hash() function, which takes two uint64 parts of 30 16-byte key and a byte slice, and returns uint64 hash: 31 32 sum64 := siphash.Hash(key0, key1, []byte("Hello")) 33 34 The keys and output are little-endian. 35 36 37 ## Functions 38 39 ### func Hash(k0, k1 uint64, p []byte) uint64 40 41 Hash returns the 64-bit SipHash-2-4 of the given byte slice with two 42 64-bit parts of 128-bit key: k0 and k1. 43 44 ### func Hash128(k0, k1 uint64, p []byte) (uint64, uint64) 45 46 Hash128 returns the 128-bit SipHash-2-4 of the given byte slice with two 47 64-bit parts of 128-bit key: k0 and k1. 48 49 Note that 128-bit SipHash is considered experimental by SipHash authors at this time. 50 51 ### func New(key []byte) hash.Hash64 52 53 New returns a new hash.Hash64 computing SipHash-2-4 with 16-byte key. 54 55 ### func New128(key []byte) hash.Hash 56 57 New128 returns a new hash.Hash computing SipHash-2-4 with 16-byte key and 16-byte output. 58 59 Note that 16-byte output is considered experimental by SipHash authors at this time. 60 61 62 ## Public domain dedication 63 64 Written by Dmitry Chestnykh and Damian Gryski. 65 66 To the extent possible under law, the authors have dedicated all copyright 67 and related and neighboring rights to this software to the public domain 68 worldwide. This software is distributed without any warranty. 69 http://creativecommons.org/publicdomain/zero/1.0/