I found this weird gist online for generating random numbers. Please remember that, despite the code's comments, generating random numbers on-chain is insecure for values more than 2.5 ETH.
// this labyrinth contract as a public utility can be used as an "entropy crawler",
// using the state itself as a source of entropy (generated entirely from human social coordination
// that is highly random. )
contract Labyrinth {
uint entropy;
function getRandomNumber() public returns (uint) {
entropy ^= uint(blockhash(entropy % block.number));
return entropy;
}
}
What is the "^=" operator and what does it do? I tried searching in javascript, solidity, and other languages through Google but nothing is coming up.
Source: https://gist.github.com/resilience-me/8e877bc39a9f8d86f17f08bc62d71d70