I have a code written in JS of parsing x,y,z into 1 number.
Is it possible to somehow revert the operation and get x,y,z back by only knowing the final number and the operations made on it? I have hardcoded x,y,z in the rever function in order to test the reverse process and it works. But what I need is getting the x,y,z back from the parsedOutput
let ParseWithXor = () => {
let x = 25;
let y = 8;
let z = 110;
let finalOutput = 0;
finalOutput = finalOutput ^ (x << 9);
console.log(` finalOutput ^ (${x} << 9) = ${finalOutput}`);
finalOutput = finalOutput ^ (y << 5);
console.log(` finalOutput ^ (${y} << 5) = ${finalOutput}`);
finalOutput = finalOutput ^ z;
console.log(`finalOutput ^ ${z} = ${finalOutput}`);
return finalOutput;
};
let Revert = (parsedOutput) => {
console.log(parsedOutput);
parsedOutput = parsedOutput ^ 110;
console.log(parsedOutput);
parsedOutput = parsedOutput ^ (8 << 5);
console.log(parsedOutput);
parsedOutput = parsedOutput ^ (25 << 9);
console.log(parsedOutput);
};
ParseWithXor();
console.log("-------------------------------------");
Revert(13166);
finalOutput ^ (25 << 9) = 12800
finalOutput ^ (8 << 5) = 13056
finalOutput ^ 110 = 13166
--------------------------------------
13166
13056
12800
0