No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
config.m4
keccak256.c
php_keccak256.h
test.php

README.md

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 https://github.com/RnDevelover/Keccak256PHP.git
  • cd Keccak256PHP
  • phpize
  • ./configure --enable-keccak256
  • make
  • copy modules/keccak256.so to your php extension directory.
  • enable extension by adding extension=keccak256.so to your php.ini

Usage:

$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.

Credits

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

License

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.