3 ms·
if your n isn’t a power of two, it may produce numbers larger than n This is the biggest problem. The others are not such big problems as I don't need
by TekMol 6y ago
if your n isn’t a power of two,
it may produce numbers larger
than n
This is the biggest problem.
The others are not such big problems as I don't need strong resemblence to real randomness.
- Someone 6y agoI can’t look into your use case, but I’m not sure you realize how spectacularly bad xoring with a fixed value is as a way to generate a ‘random’ permutation. For example, it will still alternate odd and even numbers. Also, an adversary can derive the xor key from a single sample, and predict the entire sequence from it.
- TekMol 6y agoAlterning odd and even numbers is fine. There is no adversary. The use case is not about security.