For a demo project, I want to create a hashing function with a very high probability of collision. Something simple is fine since the aim of the project is NOT security – but to demonstrate hash collisions.
Can anyone help me get started with an algorithm, or a sample implementation, or just point me in the right direction?
I am doing this in Python, though maybe that should not matter.
You could use the sum of the characters in a string. It’s the first hash function I was taught back when I was first learning BASIC in high school, and I ran into the collision problem right away and had to figure out how to deal with it.
Transpositions are easily achieved by swapping strings or even words. For more fun you could also make it case-insensitive:
I’ll even give you a sample collision for that last one: Jerry Kindall -> Dillan Kyrjer 🙂