Skip to content

Instantly share code, notes, and snippets.

@wilson1000
Forked from jed/LICENSE.txt
Last active October 1, 2018 11:23
Show Gist options
  • Save wilson1000/2cf55d5e610f5c3fe894083546d9d66e to your computer and use it in GitHub Desktop.
Save wilson1000/2cf55d5e610f5c3fe894083546d9d66e to your computer and use it in GitHub Desktop.
Generate random UUIDs

UUID

Returns a random v4 UUID of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where each x is replaced with a random hexadecimal digit from 0 to f, and y is replaced with a random hexadecimal digit from 8 to b.

!function (e) {
document.getElementById(e) && (document.getElementById(e).value = function e(t) {
return t ? (t ^ 16 * Math.random() >> t / 4).toString(16) : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, e)
}())
}("token");
function b(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,b)}
DO WTF YOU WANT TO PUBLIC LICENSE
Version 3, October 2018
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WTF YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WTF YOU WANT TO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment