Skip to Content
Ethereum Cookbook
book

Ethereum Cookbook

by Manoj P R
August 2018
Intermediate to advanced
404 pages
11h 19m
English
Packt Publishing
Content preview from Ethereum Cookbook

How to do it...

  1. To calculate the SHA-3 (keccak-256) hash of something, use the keccak256/sha3 function:
keccak256(...)// ORsha3(...) // alias to keccak256
  1. The function returns the hash in bytes32 format:
keccak256(...) returns (bytes32);
  1. Since the arguments to this functions are concatenated without padding, use any of the following input formats to yield the same value:
keccak256("hello", "world")keccak256("helloworld")keccak256(0x68656c6c6f776f726c64)keccak256(68656c6c6f776f726c64)
  1. Use solidity's sha3 function to calculate the SHA-256 hash of the input. It works just like the keccak256 function:
sha256(...) returns (bytes32);
  1. Use the ecrecover function to verify the address associated with a public key. The function accepts a signed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Ethereum Dapps

Building Ethereum Dapps

Roberto Infante
Ethereum For Dummies

Ethereum For Dummies

Michael G. Solomon

Publisher Resources

ISBN: 9781789133998Supplemental Content