Created
July 16, 2018 11:06
-
-
Save simeonpashley/5aaab75e1b0e8a3a0e5d33e5d32a1d7a to your computer and use it in GitHub Desktop.
create uuid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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