{"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","TestCases":[{"Name":"directly set","Code":"arrayBufferToHexString(saltVal);","IsDeferred":false},{"Name":"push values","Code":"bytesToHexString(saltVal)","IsDeferred":false},{"Name":"buf2hex()","Code":"buf2hex(saltVal)","IsDeferred":false}]}