You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
698 B
JavaScript
33 lines
698 B
JavaScript
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;
|
|
}
|