https://github.com/wontonst/py-rollinghash
packaged python implementation of a rolling hash function
https://github.com/wontonst/py-rollinghash
hash-functions hashing rolling-hash-functions
Last synced: 9 months ago
JSON representation
packaged python implementation of a rolling hash function
- Host: GitHub
- URL: https://github.com/wontonst/py-rollinghash
- Owner: wontonst
- Created: 2017-05-11T01:29:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-16T16:30:05.000Z (over 8 years ago)
- Last Synced: 2025-01-29T13:28:36.895Z (11 months ago)
- Topics: hash-functions, hashing, rolling-hash-functions
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/wontonst/py-rollinghash)
# RollingHash #
This is a python implementation of a rolling hash function. The implementation
is based off the [wikipedia article](https://en.wikipedia.org/w/index.php?title=Rolling_hash&oldid=751411496#Rabin-Karp_rolling_hash).
# Installation #
The easiest way to install is simply ```pip install rollinghash```
Alternatively you can clone this repository and run ```pip install /path/to/rollinghash```
# Usage & API #
This package is very simple to use
```
import rollinghash
a = rollinghash.RollingHash()
# or alternatively
a = rollinghash.RollingHash('some stuff to hash first')
# to add to the window
a.push('some more stuff') # returns new hash of window
# get current hash
curr_hash = a.hash
# pop off first
a.pop() # returns new hash of window
# alternatively pop more off
a.pop(10)
```
If you pop more than there are values, it will pop everything off and return None