Cheese icon

Polynomial Rolling Hash Collision Demo

Author: guiferviz

Created:

Last Modified:

This interactive notebook demonstrates how a polynomial rolling hash processes a text to generate hash values for fixed-size substrings. The rolling hash algorithm efficiently computes the hash of each sliding window using previously computed values, making it especially useful in applications such as:

  • Duplicate content detection
  • Plagiarism detection
  • Malware signature scanning
  • String search algorithms like Rabin-Karp

In this demo, you can:

  • Input a custom text
  • Adjust the window size for substring analysis
  • Choose the base and modulus used in the hash function

The table below shows:

  • The computed hash values
  • How many times each hash appears
  • The (unique) substrings associated with each hash

When two or more different substrings yield the same hash, a collision occurs — an interesting and sometimes problematic property of hashing algorithms. Here, you can explore how often and under what parameters such collisions appear.

Initializing...
Initializing...

Input Params

Initializing...
Initializing...

Execution Results

Initializing...

Below is the list of hashes and their associated values, sorted in descending order by the number of unique substrings that produce each hash.

Initializing...
Initializing...
Initializing...