1

Is there a js function/library which gives same output as sha256 in solidity? I am saving a hash in a mapping and can access it via cli (truffle console) and see what the hash is but I would like to send this same hash as an email. So on the frontend I need to get same hash and send it over via POST request to backend which then handles the email.

0

EDIT

As pointed out in the comments, soliditySHA3 mimics Solidity's sha3/keccak256, functions, which are not related to SHA256.


web3.utils.soliditySHA3 does what you want: https://web3js.readthedocs.io/en/1.0/web3-utils.html#soliditysha3

  • 1
    As I know, there's a big difference between sha256 and sha3, which is actually a Keccak-256 hash function. – Sergey Potekhin Sep 26 at 11:44
  • 1
    You're 100% right. I have no idea why I answered this way or why the answer was accepted. :-) I'm going to edit the answer to make that clear. – smarx Sep 26 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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