Monday 23 February 2015

Creating GUIDs (UUIDs) in Javascript

With the advance of distributed systems, there is a growing need to generate unique identifiers on the client.

There are several versions of GUID algorithms. .NET ultimately wraps the CoCreateGuid function. Windows originally started with an algorithm using the machine's MAC address, but now it uses version 4 UUIDs. You can tell this because they have the form:

xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx

Although the chance of a conflict is remote in the extreme, it is good practice to use the same version scheme on both client on server. Broofa creates RFC-compliant GUIDs (both version 1 and version 4) in JavaScript. Use version 4 for uniformity with Server-side Windows.

No comments:

Post a Comment