I have a simple Solidity function as below:
function testKeccak(uint8[] buffer) public pure returns (bytes32) {
return keccak256(abi.encodePacked(buffer));
}
Testing the keccak256 hash using library from: https://github.com/modulexcite/CEX
But they yield different results.
var In = "54686973206973206A75737420612074657374"; // Assume this is a byte[], otherwise the code won't compile
Web3 w = new Web3("http://localhost:8545/");
Contract c = w.Eth.GetContract("My ABI", " My Contract Address");
var r = c.GetFunction("testKeccak").CallAsync<byte[]>(In).Result;
//Expected = 68D0D86DF8DCA7ABDAD4DA5986F7E33FA7637EE85775A64AE965E10E3841923E
//Received = FC3B317A9FB7A02E6FF7A1839EEA04A21C30D9CD15B3414FA7431F09DEEC9D9D
May I know if there is any C# library out there which can get the correct Keccak256 hash when compared to Solidity?
Best Answer
Tested: