No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

PHP extension for Ethereum's Keccak256

This extension enables keccak256() function which returns keccak256 of a given hex encoded string. Keccak256 is used for Ethereum message signing, obtaining the wallet address given a public key, and determining the function selector of smart contracts to be provided as data in transactions given a function prototype (and in ABI encoding). The idea of making an extension for PHP first comes from my experiences and secondly from this stackoverflow post.

To install this into your php developer files installed box,

  • git clone
  • cd Keccak256PHP
  • phpize
  • ./configure --enable-keccak256
  • make
  • copy modules/ to your php extension directory.
  • enable extension by adding to your php.ini


$a="cc"; // Hex encoded string. All characters are [0-9a-fA-F]
$hash=keccak256($a); echo $hash;

This function returns a hex encoded value of 32 bytes as a string of 64 characters.


Thanks to SHA3 implementation at brainhub/SHA3IUF. I used relevant parts of their implementation. I adopted to PHP using the documentation in here.


This code belongs to public. You can utilize it any way you like. But I would suggest attribution to brainhub since most of the stuff belongs to this guy. I only integrated parts.