I have some code on my PHP powered site that creates a random hash (using sha1()
) and I use it to match records in the database. This is to obfuscate things like id's in query strings which can (and usually are) sequential, and I don't want anyone changing it in the query string to get other information.
What are the chances of a collision? Should I generate the hash, then check first if it's in the database (I'd rather avoid an extra query) or automatically insert it, based on the probability that it probably won't collide with another.
Thank you!