|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65891 PHP is missing a sha3() function
Submitted: 2013-10-13 21:58 UTC Modified: 2017-03-11 17:21 UTC
Avg. Score:4.7 ± 0.5
Reproduced:26 of 27 (96.3%)
Same Version:14 (53.8%)
Same OS:20 (76.9%)
From: scott dot baker at gmail dot com Assigned: nikic (profile)
Status: Closed Package: hash related
PHP Version: 5.5.5RC1 OS: Linux
Private report: No CVE-ID: None
 [2013-10-13 21:58 UTC] scott dot baker at gmail dot com
PHP has md5() and sha1() functions, but there is no sha3() function. Now that keccak has been officially declared the winner, PHP needs a sha3() function to match.

Optionally support could be added to hash() for keccak, but I think a standalone sha3() would be preferable.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-13 22:00 UTC] scott dot baker at gmail dot com
There has already been some work on this, it probably just needs to be merged in to core PHP?
 [2013-10-14 06:04 UTC]
I would rather add it to the hash extension, more consistent.
 [2013-10-15 16:50 UTC] scott dot baker at gmail dot com
Perhaps we could have support for both hash() and sha3() methods? 

I really like the sha3() method that strawbrary wrote. It's very logical and easy to remember. hash() requires me to remember the order of parameters, and the hash name. sha3() seems more direct.
 [2013-10-15 17:18 UTC]
I agree with Pierre. This is a hash function, so it belongs in the hash extension. There is no point in adding an individual function for every single hash type.
 [2014-07-12 19:57 UTC] ryacko at gmail dot com
Except that SHA-3 is a hash function with a variable length and variable security margin.

One could add the four SHA3 standards, but that wouldn't make available all the possible ways to use SHA3.

It could be used as stream cipher for instance.
 [2015-11-11 14:06 UTC] divinity76 at gmail dot com
add it to the hash function and stop whining about sha3(), once its in the hash() it can _very_ easily be polyfilled if you want it. however, a slight problem is that sha3 is variable-length, so hash() needs to be modified to take a new argument of output size
 [2017-03-11 17:21 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2017-03-11 17:21 UTC]
The hash extension supports sha3 as of PHP 7.1, using the names sha3-224, sha3-256, sha3-384, sha3-512. Relevant commit:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 08:03:36 2021 UTC