// Solidity pseudo-random function:
function random() private view returns (uint) {
// sha3 and now have been deprecated
return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, players)));
// convert hash to integer
// players is an array of entrants
}
// invoke random function in a pickWinner example function
function pickWinner() public {
uint index=random()%players.length;
}
function random() private view returns(uint){
uint source = block.difficulty + now;
bytes memory source_b = toBytes(source);
return uint(keccak256(source_b)) % 100;
}