Skip to content

jbaikge/rabinkarp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rabinkarp

Rabin-Karp implementation for Golang's hash package

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

About

Golang Rabin-Karp hash

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages