I have a bunch of ids for some content, and I have an url with a GET parameter like this: id=202
(where 202
is the ID of the content the user wants to watch). I want to avoid this, and convert the ID to a string with random characters and numbers, like YouTube does (example: watch?v=QEllLECo4OM
), and then convert it again to an integer, so I can fetch the content.
I thought about using a table with every ID and a string, and whenever a user uploads something new, I generate a random string and check it inside that table to avoid repetitions.
Is this the only way of doing it? Or is there a better algorithm for this?
Thanks.