Skip to content

Instantly share code, notes, and snippets.

@simeonpashley
Created July 16, 2018 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simeonpashley/5aaab75e1b0e8a3a0e5d33e5d32a1d7a to your computer and use it in GitHub Desktop.
Save simeonpashley/5aaab75e1b0e8a3a0e5d33e5d32a1d7a to your computer and use it in GitHub Desktop.
create uuid
createUuid: function() {
// Copy & paste form http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript/2117523#2117523
// This is a cryptograhically not secure implementation, but is good enough for the given use case
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, function(c) {
var r = Math.random() * 16|0, v = c == 'x' ? r : (r&0x3|0x8)
return v.toString(16)
})
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment