我有一个用JS写的代码,可以把x,y,z解析成1个数字.
有没有可能只知道最终的数字和对它进行的操作,就能以某种方式恢复操作并得到x,y,z? 为了测试反向过程,我在rever函数中硬编码了x,y,z,它起作用了.但我需要的是从parsedOutput中取回x,y,z
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