adamhalasz / uniqid

Unique ID Generator
https://adamhalasz.com
617 stars 49 forks source link

consider using the full hostname #2

Closed Offirmo closed 8 years ago

Offirmo commented 8 years ago

In my company, all machines in Paris office have a name that starts with "PAR". Taking the 3 first letters is not enough ^^

adamhalasz commented 8 years ago

@Offirmo that makes sense :P I will think about a better way over the weekend. @khalilTN is right, the mac address would be the ultimate solution for making the ID's completely unique, however I also want their length to be as small as possible.

Thanks, Adam

isayme commented 8 years ago

How about hash hostname ? like md5 or something else.

Event we can use full hostname, we should think about that hostname can contain other characters beyond alphanumeric characters.

khalilTN commented 8 years ago

I thought about md5 too, but md5 generates 32 hexadecimal digits, the uid will be long and that violates @adamhalasz length constraint. In my own, there can be 2 procedures :

What do you think ?

isayme commented 8 years ago

we can still use first 3 letters of md5 result. however, mac address is another option.

and how about hash current time ?

khalilTN commented 8 years ago

i think using the first 3 letters would rize the collision probability

adamhalasz commented 8 years ago

Hey guys I added MAC Address support to v3. It's a bit longer but still just 18 bytes. There are also 2 new weaker functions with shorter length: uniqid.process() and uniqid.time()

@Offirmo I believe this solves your issue.

Thanks, Adam