Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query String unique string generator?

Once I've asked about : how does apparently random query string/urls are being generated.

It can be found in many places :

http://www.youtube.com/watch?v=IMl7pvaWzh8
                                   ^
                                   |
                                   +---------------- 

http://jsfiddle.net/xeolabs/LSTKM/light/
                              ^
                              |
                              +---------------- 

http://jsbin.com/asapay/1/edit
                   ^
                   |
                   +---------------- 

I was told ( and it seems logic) that when the server pick a new url , it doesnt check if it is free ( wasn't chosen before)

Also , I was told it can be result of a formula such as: f(n+1) = f(n)+1 ( so it is not random at all.

so the new url param is generated as a result of the last generated url param.

my Question :

where can I found such generators functions ?

of course I can build one of my own such 17=16+1 but i'm looking something ready like :

f(n+1) = f(n)+1 where there is a usages of uppercase , lower case , numbers. and
of course minimum collisions and zero predictions.

you know , something professional...

I'm just curious how google/youtube/jsbin/jsfiddle does it with a millions of requests a day.

like image 211
Royi Namir Avatar asked Dec 23 '12 20:12

Royi Namir


1 Answers

Thinking out loud, but you could just precalculate a huge list of unique hashes and assign them to any new inputs. Precalculating will ensure you can keep checking for collisions as it's not required in real time. You can look into generating random hashes in this question.

like image 64
keyboardP Avatar answered Sep 28 '22 05:09

keyboardP