pragma solidity >=0.4.14 <0.7.0; contract Challenge { event Log(string); uint256[][] data = [[0, 10, 8, 9, 8, 22637],[11, 6, 2, 13, 0, 16996],[13, 5, 1, 0, 10, 24429],[0, 11, 11, 8, 9, 25181],[1, 3, 8, 3, 4, 26727],[4, 4, 9, 9, 6, 24428],[7, 5, 9, 2, 10, 17774],[2, 4, 4, 9, 0, 31858],[10, 11, 12, 9, 6, 24682],[11, 12, 10, 9, 2, 17526],[6, 1, 3, 0, 11, 21355],[1, 9, 8, 6, 0, 23638],[6, 11, 8, 9, 7, 23647],[11, 7, 10, 7, 11, 24431]]; uint256[] csts; uint256 checksum = 7702; function check(string memory flag) private returns (bool){ bytes memory b = bytes(flag); if( b.length != 28) { return false; } for(uint256 i=0;i<b.length/2;i++){ csts.push((uint256(uint8(b[i*2])) * 256) + uint256(uint8(b[i*2+1])) ); } uint256 x; for(uint256 i=0;i<14;i++){ x = csts[data[i][0]] ^ csts[data[i][1]] ^ csts[data[i][2]] ^ csts[data[i][3]] ^ csts[data[i][4]]; emit Log("here"); if (x != csts[data[i][5]]) { emit Log("no"); } emit Log("yes"); } return true; } function checkFlag(string memory flag) public returns (string memory) { if(check(flag) == true){ return "Correct!"; }else{ return "Wrong."; } } }
0.4.18