Will XORing any data with random data produce a random result?

23 Views Asked by At

Provided you have a stream of input data and a stream of random data both in the set (0,1). The random is data truly random, that is, unpredictable by the user and has an equal probability of returning either a 0 or a 1. The input and random data are XORed together to produce the output data.

Is there any way to predict the output data if you know the input data, or is there any way to skew the distribution of the the output if you control the input data?

And part 2: does this principle hold true for any n, where the following pseudocode will produce a truly random output (that is unpredictable and unskewed distribution)?

(input + random(0, n)) % n