{"ScriptPreparationCode":"var saltVal = crypto.getRandomValues(new Uint8Array(16));\r\n\r\nfunction arrayBufferToHexString(bytes) {\r\n bytes = new Uint8Array(bytes);\r\n var hex = new Array(bytes.length);\r\n for (let i = 0; i \u003C bytes.length; i\u002B\u002B) {\r\n hex[i] = (\u00220\u0022 \u002B bytes[i].toString(16)).slice(-2);\r\n }\r\n return hex.join(\u0022\u0022);\r\n}\r\n\r\nfunction bytesToHexString(bytes) {\r\n bytes = new Uint8Array(bytes);\r\n var hexBytes = [];\r\n for (var i = 0; i \u003C bytes.length; i\u002B\u002B) {\r\n var byteString = bytes[i].toString(16);\r\n if (byteString.length \u003C 2) byteString = \u00220\u0022 \u002B byteString;\r\n hexBytes.push(byteString);\r\n }\r\n return hexBytes.join(\u0022\u0022);\r\n}\r\n\r\nfunction buf2hex(buffer) { // buffer is an ArrayBuffer\r\n return [...new Uint8Array(buffer)]\r\n .map(x =\u003E x.toString(16).padStart(2, \u00270\u0027))\r\n .join(\u0027\u0027);\r\n}\r\n\r\nfunction hex(arrayBuffer)\r\n{\r\n \tconst asciiCodes = new Uint8Array(\r\n \tArray.prototype.map.call(\r\n \t\u00220123456789abcdef\u0022,\r\n \tchar =\u003E char.charCodeAt()\r\n \t)\r\n\t);\r\n \r\n const buff = new Uint8Array(arrayBuffer);\r\n const charCodes = new Uint8Array(buff.length * 2);\r\n\r\n for (let i = 0; i \u003C buff.length; \u002B\u002Bi)\r\n {\r\n charCodes[i * 2] = asciiCodes[buff[i] \u003E\u003E\u003E 4];\r\n charCodes[i * 2 \u002B 1] = asciiCodes[buff[i] \u0026 0xf];\r\n }\r\n\r\n return String.fromCharCode(...charCodes);\r\n}\r\n\r\nfunction hex2(arrayBuffer)\r\n{\r\n return Array.prototype.map.call(\r\n new Uint8Array(arrayBuffer),\r\n n =\u003E n.toString(16).padStart(2, \u00220\u0022)\r\n ).join(\u0022\u0022);\r\n}","TestCases":[{"Name":"directly set","Code":"arrayBufferToHexString(saltVal);","IsDeferred":false},{"Name":"push values","Code":"bytesToHexString(saltVal)","IsDeferred":false},{"Name":"buf2hex()","Code":"buf2hex(saltVal)","IsDeferred":false},{"Name":"precomputed ASCII with shift","Code":"hex(saltVal)","IsDeferred":false},{"Name":"array prototype map","Code":"hex2(saltVal)","IsDeferred":false}]}