I have a counter with a known maximum (called max). max can be big (actually it will be either 36^40 - 1 or 62^40 - 1).
I want a bijection b from [0..max] to [0..max] with the following property: b(n+1) not easily guessable from b(n).
I am NOT searching for a cryptographically secure function, I just want as much entropy as possible to obfuscate a little the output of a counter.
The function must be doable in PHP. This allows all the functions PHP does.
I do not think this question is answerable in it’s current form. The criterion
is not well-defined. You have given no metric or quantifiable constraint. Since you go on to write that you are “NOT searching for a cryptographically secure function” and mention in the comments that you “do not truly care that anyone find the function”, it is unclear why you need the bijection at all.
However, here are some ideas that may help you either find a bijection you’re happy with or clarify your question so others can help.
Any linear polynomial invertible modulo
maxwill work. That is, a polynomial of the formgives a bijection if and only if
The easiest case is
a=1andb=0, so thatb(n) = n, which seems to satisfy your vague constraints.If you want to get fancy with it, you could change
aandboften, say be generating a random number (but be sure to check thatgcd(a,max) = 1or you will not get a bijection).