✅ Creating random & unique page id
I want to generate id for a page that will be used to access it, something like example.com/2121424221. But generated id should have about 10-15 digits and be unique. How could I do that?
7 Replies
Do you have a list of IDs which you have generated already?
Sequential IDs masked with sqids
Maybe nanoid with limited size and custom alphabet
The most trivial algorithm is
do { id = GenerateRandomNumber(); } while (!AlreadyGenerated(id));
Or current UNIX timestamp + random value
I have Page table in my database
Looks good to me. But how could I retrive list of ids from my db using EF?
Uh
Like you would retrieve anything else?
In method that I speaking about no
Thanks!