Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close
PACKAGE

package fnv
import "bitbucket.org/ww/fnv"

 Fowler-Noll-Vo 64-bit hash implementation for Go.

 This is public domain software written by William Waites <ww@styx.org> in 2011
 Do whatever you like with it. No warranties express or implied. Caveat compilator.

 You should be able to install the fnv package by doing::

    goinstall bitbucket.org/ww/fnv

 Example use::

    import (
        "bitbucket.org/ww/fnv"
        "fmt"
    )

    ...

    h := fnv.NewFNV1a()
    h.Write([]byte("hello world"))
    fmt.Printf("%x", h.Sum64())

 The pseudo-code from http://en.wikipedia.org/wiki/Fowler-Noll-Vo_hash_function
 for FNV1 is::

    hash = FNV_offset_basis
    for each octet_of_data to be hashed
         hash = hash XOR octet_of_data
         hash = hash * FNV_prime
    return hash

 where FNV_offset_basis and FNV_prime are constants of the algorithm. The (apparently
 better) FNV1a algorithm has the XOR and multiplication steps reversed.

 The hash generated by the Sum() method is in host-endian form so be careful
 in heterogeneous environments


CONSTANTS

const FNV_OFFSET uint64 = 14695981039346656037

const FNV_PRIME uint64 = 1099511628211


FUNCTIONS

func NewFNV1() hash.Hash64
Allocate  new FNV1 hash

func NewFNV1a() hash.Hash64
Allocate a new FNV1a hash


TYPES

type FNV1 uint64
FNV1 hash type

func (h *FNV1) Reset()

func (h *FNV1) Size() int

func (h *FNV1) Sum() []byte
Return the 64-bit hash as a slice of bites. Caution with network use:
this is in host-endian form

func (h *FNV1) Sum64() uint64

func (h *FNV1) Write(buf []byte) (int, os.Error)

type FNV1a uint64
FNV1a Hash type

func (h *FNV1a) Reset()

func (h *FNV1a) Size() int

func (h *FNV1a) Sum() []byte
Return the 64-bit hash as a slice of bites. Caution with network use:
this is in host-endian form

func (h *FNV1a) Sum64() uint64

func (h *FNV1a) Write(buf []byte) (int, os.Error)


SUBDIRECTORIES

	.hg

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.