{"ScriptPreparationCode":"\r\n// Jeff Ward v7\r\nvar lut = []; for (var i=0; i\u003C256; i\u002B\u002B) { lut[i] = (i\u003C16?\u00270\u0027:\u0027\u0027)\u002B(i).toString(16); }\r\nfunction e7()\r\n{\r\n var d0 = Math.random()*0xffffffff|0;\r\n var d1 = Math.random()*0xffffffff|0;\r\n var d2 = Math.random()*0xffffffff|0;\r\n var d3 = Math.random()*0xffffffff|0;\r\n return lut[d0\u00260xff]\u002Blut[d0\u003E\u003E8\u00260xff]\u002Blut[d0\u003E\u003E16\u00260xff]\u002Blut[d0\u003E\u003E24\u00260xff]\u002B\u0027-\u0027\u002B\r\n lut[d1\u00260xff]\u002Blut[d1\u003E\u003E8\u00260xff]\u002B\u0027-\u0027\u002Blut[d1\u003E\u003E16\u00260x0f|0x40]\u002Blut[d1\u003E\u003E24\u00260xff]\u002B\u0027-\u0027\u002B\r\n lut[d2\u00260x3f|0x80]\u002Blut[d2\u003E\u003E8\u00260xff]\u002B\u0027-\u0027\u002Blut[d2\u003E\u003E16\u00260xff]\u002Blut[d2\u003E\u003E24\u00260xff]\u002B\r\n lut[d3\u00260xff]\u002Blut[d3\u003E\u003E8\u00260xff]\u002Blut[d3\u003E\u003E16\u00260xff]\u002Blut[d3\u003E\u003E24\u00260xff];\r\n}\r\n\r\n// Jeff Ward v7 window.crypto\r\nvar lut = []; for (var i=0; i\u003C256; i\u002B\u002B) { lut[i] = (i\u003C16?\u00270\u0027:\u0027\u0027)\u002B(i).toString(16); }\r\nfunction e7_crypto()\r\n{\r\n var d = new Uint32Array(4);\r\n window.crypto.getRandomValues(d);\r\n return lut[d[0]\u00260xff]\u002Blut[d[0]\u003E\u003E8\u00260xff]\u002Blut[d[0]\u003E\u003E16\u00260xff]\u002Blut[d[0]\u003E\u003E24\u00260xff]\u002B\u0027-\u0027\u002B\r\n lut[d[1]\u00260xff]\u002Blut[d[1]\u003E\u003E8\u00260xff]\u002B\u0027-\u0027\u002Blut[d[1]\u003E\u003E16\u00260x0f|0x40]\u002Blut[d[1]\u003E\u003E24\u00260xff]\u002B\u0027-\u0027\u002B\r\n lut[d[2]\u00260x3f|0x80]\u002Blut[d[2]\u003E\u003E8\u00260xff]\u002B\u0027-\u0027\u002Blut[d[2]\u003E\u003E16\u00260xff]\u002Blut[d[2]\u003E\u003E24\u00260xff]\u002B\r\n lut[d[3]\u00260xff]\u002Blut[d[3]\u003E\u003E8\u00260xff]\u002Blut[d[3]\u003E\u003E16\u00260xff]\u002Blut[d[3]\u003E\u003E24\u00260xff];\r\n}\r\n\r\n\r\n// Broofa (new)\r\nfunction uuidv4_new() {\r\n return ([1e7]\u002B-1e3\u002B-4e3\u002B-8e3\u002B-1e11).replace(/[018]/g, c =\u003E\r\n (c ^ crypto.getRandomValues(new Uint8Array(1))[0] \u0026 15 \u003E\u003E c / 4).toString(16)\r\n )\r\n}\r\n\r\n// Broofa (old)\r\nfunction uuidv4_old() {\r\n return \u0027xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\u0027.replace(/[xy]/g, function(c) {\r\n var r = Math.random() * 16 | 0, v = c == \u0027x\u0027 ? r : (r \u0026 0x3 | 0x8);\r\n return v.toString(16);\r\n });\r\n}\r\n\r\n\r\n// Jon Surrell (not real UUID)\r\nfunction guid() {\r\n function s4() {\r\n return Math.floor((1 \u002B Math.random()) * 0x10000)\r\n .toString(16)\r\n .substring(1);\r\n }\r\n return s4() \u002B s4() \u002B \u0027-\u0027 \u002B s4() \u002B \u0027-\u0027 \u002B s4() \u002B \u0027-\u0027 \u002B\r\n s4() \u002B \u0027-\u0027 \u002B s4() \u002B s4() \u002B s4();\r\n}\r\n\r\n// My Test\r\nvar UUID = (new function() {\r\n this._lut = []; for (var i = 0; i \u003C 256; i\u002B\u002B) {\r\n this._lut[i] = (i \u003C 16 ? \u00270\u0027 : \u0027\u0027) \u002B (i).toString(16);\r\n };\r\n\r\n this._format = function (rarr) {\r\n return \u0027\u0027 \u002B\r\n this._lut[rarr[0] \u0026 0xff] \u002B this._lut[rarr[0] \u003E\u003E 8 \u0026 0xff] \u002B this._lut[rarr[0] \u003E\u003E 16 \u0026 0xff] \u002B this._lut[rarr[0] \u003E\u003E 24 \u0026 0xff] \u002B \u0027-\u0027 \u002B\r\n this._lut[rarr[1] \u0026 0xff] \u002B this._lut[rarr[1] \u003E\u003E 8 \u0026 0xff] \u002B \u0027-\u0027 \u002B\r\n this._lut[rarr[1] \u003E\u003E 16 \u0026 0x0f | 0x40] \u002B this._lut[rarr[1] \u003E\u003E 24 \u0026 0xff] \u002B \u0027-\u0027 \u002B\r\n this._lut[rarr[2] \u0026 0x3f | 0x80] \u002B this._lut[rarr[2] \u003E\u003E 8 \u0026 0xff] \u002B \u0027-\u0027 \u002B\r\n this._lut[rarr[2] \u003E\u003E 16 \u0026 0xff] \u002B this._lut[rarr[2] \u003E\u003E 24 \u0026 0xff] \u002B\r\n this._lut[rarr[3] \u0026 0xff] \u002B this._lut[rarr[3] \u003E\u003E 8 \u0026 0xff] \u002B\r\n this._lut[rarr[3] \u003E\u003E 16 \u0026 0xff] \u002B this._lut[rarr[3] \u003E\u003E 24 \u0026 0xff];\r\n };\r\n\r\n this._getRandomness = function () {\r\n if (\u0027crypto\u0027 in window \u0026\u0026 \u0027Uint32Array\u0027 in window) {\r\n var dvals = new Uint32Array(4);\r\n window.crypto.getRandomValues(dvals);\r\n return dvals\r\n }\r\n return [\r\n Math.random() * 0x100000000 \u003E\u003E\u003E 0,\r\n Math.random() * 0x100000000 \u003E\u003E\u003E 0,\r\n Math.random() * 0x100000000 \u003E\u003E\u003E 0,\r\n Math.random() * 0x100000000 \u003E\u003E\u003E 0,\r\n ];\r\n };\r\n\r\n this.generate = function () {\r\n return this._format(this._getRandomness());\r\n };\r\n}());\r\n\r\nvar UUID2 = (new function () {\r\n this._lut = []; for (var i = 0; i \u003C 256; i\u002B\u002B) {\r\n this._lut[i] = (i \u003C 16 ? \u00270\u0027 : \u0027\u0027) \u002B (i).toString(16);\r\n };\r\n\r\n this._format = function (rarr) {\r\n return [\r\n this._lut[rarr[0] \u0026 0xff] , this._lut[rarr[0] \u003E\u003E 8 \u0026 0xff] , this._lut[rarr[0] \u003E\u003E 16 \u0026 0xff] , this._lut[rarr[0] \u003E\u003E 24 \u0026 0xff] , \u0027-\u0027 ,\r\n this._lut[rarr[1] \u0026 0xff] , this._lut[rarr[1] \u003E\u003E 8 \u0026 0xff] , \u0027-\u0027 ,\r\n this._lut[rarr[1] \u003E\u003E 16 \u0026 0x0f | 0x40] , this._lut[rarr[1] \u003E\u003E 24 \u0026 0xff] , \u0027-\u0027 ,\r\n this._lut[rarr[2] \u0026 0x3f | 0x80] , this._lut[rarr[2] \u003E\u003E 8 \u0026 0xff] , \u0027-\u0027 ,\r\n this._lut[rarr[2] \u003E\u003E 16 \u0026 0xff] , this._lut[rarr[2] \u003E\u003E 24 \u0026 0xff] ,\r\n this._lut[rarr[3] \u0026 0xff] , this._lut[rarr[3] \u003E\u003E 8 \u0026 0xff] ,\r\n this._lut[rarr[3] \u003E\u003E 16 \u0026 0xff] , this._lut[rarr[3] \u003E\u003E 24 \u0026 0xff]\r\n ].join(\u0027\u0027)\r\n };\r\n\r\n this._getRandomness = function () {\r\n if (\u0027crypto\u0027 in window \u0026\u0026 \u0027Uint32Array\u0027 in window) {\r\n var dvals = new Uint32Array(4);\r\n window.crypto.getRandomValues(dvals);\r\n return dvals\r\n }\r\n return [\r\n Math.random() * 0x100000000 \u003E\u003E\u003E 0,\r\n Math.random() * 0x100000000 \u003E\u003E\u003E 0,\r\n Math.random() * 0x100000000 \u003E\u003E\u003E 0,\r\n Math.random() * 0x100000000 \u003E\u003E\u003E 0,\r\n ];\r\n };\r\n\r\n this.generate = function () {\r\n return this._format(this._getRandomness());\r\n };\r\n}());","TestCases":[{"Name":"Jeff Ward v7","Code":"e7();","IsDeferred":false},{"Name":"Jon Surrell (not real UUID)","Code":"guid();","IsDeferred":false},{"Name":"Broofa (new)","Code":"uuidv4_new();","IsDeferred":false},{"Name":"Broofa (old)","Code":"uuidv4_old();","IsDeferred":false},{"Name":"My Test","Code":"UUID.generate();","IsDeferred":false},{"Name":"Jeff Ward v7 window.crypto","Code":"e7_crypto();","IsDeferred":false},{"Name":"My Test v2 (array.join)","Code":"UUID2.generate();","IsDeferred":false}]}