pragma solidity ^0.4.24; contract SimpleStore { function _bytes32ArrayToUintArray(bytes32[] _bytes32Array) private pure returns(uint[]) { uint lenIn = _bytes32Array.length; uint lenOut = lenIn * 32; uint[] memory ret = new uint[](lenOut); uint cnt = 0; for(uint i = 0; i < lenIn; i++){ for(uint j = 0; j < 32; j++){ ret[cnt++] = uint(_bytes32Array[i][j]); } } return ret; } function _getRandomUintArray(uint len) private view returns(uint[]) { uint nowLocal = now; address msgSender = msg.sender; uint times = 1 + uint(len / 32); bytes32[] memory bytes32Array = new bytes32[](times); uint i; for(i = 0; i < times; i++){ uint seed = i + 1234567890; bytes32Array[i] = keccak256(seed, nowLocal, msgSender); } uint[] memory buf = _bytes32ArrayToUintArray(bytes32Array); uint[] memory ret = new uint[](len); for(i = 0; i < len; i++){ ret[i] = buf[i]; } return ret; } function test(uint len) public view returns(uint[]) { return _getRandomUintArray(len); } }
0.4.24