I have a seed-calculating thing that uses JavaScript (Functions properly). I'm attempting to convert it into Python (For a more detailed project) using the JS2PY library.
My code:
import js2py
hasCode = js2py.eval_js('function hashCode(s) {let h = 0; for (let i = 0; i < s.length; i++) {h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;} return h;}')
getSeed = js2py.eval_js('function getSeed(s) {let x = BigInt(hashCode(s)); if (/^[\-\+0-9]*$/.test(s)) {try {let y = BigInt(s); if (BigInt.asIntN(64, y) !== y) {throw RangeError();} x = y;} catch (err) {}} return { high: x >> 32n, low: BigInt.asIntN(32, x) };}')
output = js2py.eval_js('function output() {let seed = -734744700160476640; print("Copy this output - " + seed.high, seed.low);}')
output()
Should you use this in, say, a HTML file, the JavaScript will produce a "High" and "Low" of the seed input (Here it is -734744700160476640, but I would allow users to input their own seed).
The command log explains that there's syntax errors in files that I'm assuming is from the library. You can probably tell I'm a little inexperienced so if it's my own code that's broken, shout it out. I don't know if JS2PY is outdated or if there's better options out there. I couldn't find any myself.