I am following the blog post "A practical use of multiplicative inverses" to implement a pseudo-hash function that needs to be reversible. The idea works perfectly, but I would like to understand in more detail how the results can be provably unique – and unfortunately my ability falls short.
Ignoring the inverse element, I would like to understand how for any input (up to $m$), the result will be unique.
The important excerpt from the blog post is as follows:
Start by picking a large number $m$, much larger than the number of tokens you’re ever going to need to generate. Let’s say 1000000000. Now pick any number $x$ coprime to that; lets say 387420489.
$encoded = invoiceNumber \times 387420489 \bmod 1000000000$
This gives us a unique random-seeming number between 0 and 999999999. We know the number will be different for every input.
I would like to understand why the encoded number will be different for every input.
Thanks in advance