{"ScriptPreparationCode":"var input = \u0022Hello World!\u0022;\r\n\r\nfunction javaStringHash(str) {\r\n var hash = 0;\r\n for (var i = 0; i \u003C str.length; i\u002B\u002B) {\r\n hash = ((hash \u003C\u003C 5) - hash) \u002B str.charCodeAt(i);\r\n hash |= 0; // Convert to 32bit integer\r\n }\r\n return hash;\r\n}\r\n\r\nfunction djb2(str) {\r\n var hash = 5381;\r\n for (var i = 0; i \u003C str.length; i\u002B\u002B) {\r\n hash = ((hash \u003C\u003C 5) \u002B hash) \u002B str.charCodeAt(i);\r\n hash |= 0; // Convert to 32bit integer\r\n }\r\n return hash;\r\n}\r\n\r\nfunction djb2Reduce(str) {\r\n return str.split(\u0022\u0022).reduce(function(a, b) {\r\n a = ((a \u003C\u003C 5) \u002B a) \u002B b.charCodeAt(0);\r\n return a \u0026 a;\r\n }, 0);\r\n}\r\n\r\n\r\nfunction cyrb53(str, seed) {\r\n var h1 = 0xdeadbeef ^ seed;\r\n var h2 = 0x41c6ce57 ^ seed;\r\n for (var i = 0; i \u003C str.length; i\u002B\u002B) {\r\n var ch = str.charCodeAt(i);\r\n h1 = Math.imul(h1 ^ ch, 2654435761);\r\n h2 = Math.imul(h2 ^ ch, 1597334677);\r\n }\r\n\r\n h1 = Math.imul(h1 ^ (h1 \u003E\u003E\u003E 16), 2246822507) ^ Math.imul(h2 ^ (h2 \u003E\u003E\u003E 13), 3266489909);\r\n h2 = Math.imul(h2 ^ (h2 \u003E\u003E\u003E 16), 2246822507) ^ Math.imul(h1 ^ (h1 \u003E\u003E\u003E 13), 3266489909);\r\n\r\n return 4294967296 * (2097151 \u0026 h2) \u002B (h1 \u003E\u003E\u003E 0);\r\n};","TestCases":[{"Name":"Java String Hash","Code":"javaStringHash(input)","IsDeferred":false},{"Name":"DJB2","Code":"djb2(input)","IsDeferred":false},{"Name":"cyrb53","Code":"cyrb53(input, 0)","IsDeferred":false},{"Name":"DJB2 - reduce","Code":"djb2Reduce(input)","IsDeferred":false}]}