Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jbaikge/rabinkarp

Golang Rabin-Karp hash
https://github.com/jbaikge/rabinkarp

Last synced: 9 days ago
JSON representation

Golang Rabin-Karp hash

Awesome Lists containing this project

README

        

rabinkarp
=========

Rabin-Karp implementation for [Golang's hash package](http://golang.org/pkg/hash)

Installation
------------

go get github.com/jbaikge/rabinkarp

Usage
-----

Most useful for generating numeric hashes for short []byte slices (words):

package main

import (
"fmt"
"github.com/jbaikge/rabinkarp"
)

func main() {
h := rabinkarp.New32()
words := [][]byte{
[]byte(`monkey`),
[]byte(`elephant`),
}
for _, word := range words {
h.Write(word)
fmt.Printf("%s: %d\n", word, h.Sum32())
h.Reset()
}
}

Output:

monkey: 663992827
elephant: 1878464849