const saltMaster = "xG7t;a$LN=D5"; const saltAdmin = "mXA4H_xb$g)c"; function hash(m, salt) { var result = ""; if (m.length != 24) throw "Invalid id"; for (var i = 0; i < 12; i++) { //console.log(x.charAt(i)); playground = 0; playground += salt.charCodeAt(i); playground ^= m.charCodeAt(i); playground ^= m.charCodeAt(i + 12); playground &= 0xff; playground %= 10; result += playground.toString(); } // console.log(result); return result; } function getKeys(uid) { var keys; try { keys = { User: hash(uid, saltMaster), Admin: hash(uid, saltAdmin), }; } catch (error) { keys = { err: "Invalid id" }; } return keys; }