What's the best way to achieve the equivalent hashing in Java as below in Solidity? keccak256(abi.encodePacked(arg1,arg2,...))

1 Answer 1


One simple way is to use StringBuilder to append the strings as arguments for kaccak256, then to use library web3j to use sha3 method.

    StringBuilder sb = new StringBuilder(arg1);
    byte[] hash = Hash.sha3(Numeric.hexStringToByteArray(String.valueOf(sb)));

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.