{"ScriptPreparationCode":"var data = new Uint32Array(1024);\r\n window.crypto.getRandomValues(data);\r\n var dataBuffer = new Uint8Array(data);\r\n data = String.fromCharCode.apply(null, dataBuffer);\r\n \r\n \r\n // src: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest\r\n function hex(buffer) {\r\n var hexCodes = [];\r\n var view = new DataView(buffer);\r\n for (var i = 0; i \u003C view.byteLength; i \u002B= 4) {\r\n // Using getUint32 reduces the number of iterations needed (we process 4 bytes each time)\r\n var value = view.getUint32(i)\r\n // toString(16) will give the hex representation of the number without padding\r\n var stringValue = value.toString(16)\r\n // We use concatenation and slice for padding\r\n var padding = \u002700000000\u0027\r\n var paddedValue = (padding \u002B stringValue).slice(-padding.length)\r\n hexCodes.push(paddedValue);\r\n }\r\n \r\n // Join all the hex strings into one\r\n return hexCodes.join(\u0022\u0022);\r\n }","TestCases":[{"Name":"forge","Code":"forge.md.sha1.create().update(data).digest()","IsDeferred":false},{"Name":"native","Code":"crypto.subtle.digest(\u0022SHA-1\u0022, dataBuffer ).then(function (hash) {console.log(hex(hash));});","IsDeferred":false},{"Name":"sjcl","Code":"sjcl.hash.sha1.hash(data);","IsDeferred":false},{"Name":"cryptojs","Code":"CryptoJS.SHA1(data);","IsDeferred":false}]}