Skip to content

Instantly share code, notes, and snippets.

@maurobaraldi
Last active August 29, 2015 13:58
Show Gist options
  • Save maurobaraldi/10187914 to your computer and use it in GitHub Desktop.
Save maurobaraldi/10187914 to your computer and use it in GitHub Desktop.
Javascritp UUID Lib
function generateUUID() {
var d = new Date().getTime();
var uuid = 'xxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = (d + Math.random()*16)%16 | 0;
d = Math.floor(d/16);
return (c=='x' ? r : (r&0x7|0x8)).toString(16);
});
return uuid;
};
alert(generateUUID())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment