Is there a class of hash functions that meets the following specs:
- Upper and lower bound can be specified
- Uniqueness is guaranteed as long as the input is between the upper and lower bounds
- Amount of entropy is controllable, or at least high and evenly distributed
An example of a low entropy hash function that produces unique results, and allows the upper bound to be specified is
int hash(int x,int upperBound) {
return x - (upperBound * (x \ upperBound));
}
This would produce a number between [0, upperBound), resetting back to 0 when the number can be divided by upperBound.
So lets say our upper bound is 20^3, that gives us 46656 numbers I believe. Feeding a number between 0 and 46655 should produce a unique result. Any number over will produce a collision. Providing the same number should always give the same result. Being able to control entropy would be a plus, but if it's evenly distributed and high then that will work fine too.
The end goal is to turn the number into an alpha numeric representation which can quickly be looked at to determine if it has been changed since the last time a number was requested. I should not receive the same number until all numbers have been used.
Aucun commentaire:
Enregistrer un commentaire