Skip to content

Instantly share code, notes, and snippets.

@clemgrim
Last active August 29, 2015 14:06
Show Gist options
  • Save clemgrim/0f5e01569c1be796298e to your computer and use it in GitHub Desktop.
Save clemgrim/0f5e01569c1be796298e to your computer and use it in GitHub Desktop.
function getGUID() {
return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function(c) {
var num = Math.random() *16 | 0, v = c === 'x' ? num : (num&0x3|0x8);
return v.toString(16);
});
}
function getGUID() {
function fd() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return fd() + fd() + '-' + fd() + '-' + fd() + '-' + fd() + '-' + fd() + fd() + fd();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment