I have this solidity function below. It is supposed to return the hash of a given data, but instead I get this: 0x

 function hashData (bytes32 data) public constant returns (bytes32) {
      var hash =  keccak256(data);
      return hash;
  • 2
    It works for me. May 7, 2018 at 9:32
  • Works for me as well, have you put the data in like so "data" and also instead of using var hash try using bytes32 hash
    – Gabe
    May 7, 2018 at 9:43
  • it doesn't work for byte32 also
    – maroodb
    May 7, 2018 at 9:45

1 Answer 1

function hashData (bytes32 data) public pure returns (bytes32) {
      bytes32 hash =  keccak256(data);
      return hash;

hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.