I have a table with a primary key that is auto increment. I want to have an image associated with the primary key but I don't want the primary key to be revealed. Would naming the images something like:
$filename = md5($primarykey + $secret_string) . '.jpg';
be a good solution?
I am worried that there could be a collision and a file be over written.
The other option of course is to generate a random string, check it doesnt exist as a file and store it in the database... but id prefer not to store additional data if its unnecessary.
The other option is a logical transformation youtube url style e.g 1=a 2=b but with a randomised order e.g 1=x 2=m... but then there is the chance of it being decoded... plus md5 would probably be lighter than any youtube url function.
I would guess I am dealing with over two million records so what is the likely hood of a collision? Which option would you pick or can you think of a better approach?