Is there a framework or function that allows me to use SHA3-512? I don't want a extension like Strawbrary
-
1Is that level of hashing *really necessary*? – Rob W Jun 28 '13 at 16:00
-
1@RobW SHA is a hashing algorithm, not encryption, and necessity of security depends on the task. – Glitch Desire Jun 28 '13 at 16:01
-
1Something in pure PHP sounds like it would be pretty slow. Did you really need SHA3? – Ry- Nov 07 '13 at 04:52
4 Answers
Yes sure simply you can use hash function in php
<?php
echo hash('sha3-512' , 'String you want to hash');

- 755
- 1
- 8
- 19
-
`sha3-512` does not exist in PHP. https://3v4l.org/kR8UJ It seems only HHVM has it. – Brad Jan 08 '18 at 06:00
-
5@Brad running `hash_algos()` on php7.2 shows that it 'sha3-384' does indeed exist – Brian Leishman Feb 13 '18 at 16:51
-
9
It's possible.
Maybe too late, but I've worked on a pure-PHP
implementation here:
- SHA3-224/256/384/512
- SHAKE128/256 (arbitrary output size)
LGPL 3+
- Works in
PHP 5.2+
(considerably slower on olderPHP
) - No extensions required.
- Moderately well tested.
- Based on the (public domain) reference implementation in
C
. - Arbitrary input size.
It is a simple and fast implementation in PHP
(which means far slower than C). Since this is purely "CPU-bound", PHP 7.0
runs 4x faster than PHP 5.6
. (55kB/s here)
Fine with a small input. Correctly handles a huge input, just hogs CPU
for minutes.
I hope it helps.

- 1,453
- 3
- 20
- 28

- 316
- 2
- 6
-
4I think you should watch out with implementing this yourselves for security reasons. Correctly implementing a hashing algorithm is just as important as designing an algorithm. Also consider that the reference implementation is not necessarily secure: they don't often consider timing attacks. Anyway, PHP is not the language to implement these cryptographic primitives. – user23127 Jun 08 '17 at 16:27
For those coming to this later (after this post) PHP 7.1.0 has support for SHA3-512.
Per the PHP Manual (http://php.net/manual/en/function.hash-algos.php) the hash_algos() function will output your system's available hash algorithms. The following code will output your system's available hash algorithms:
<?php
echo "<pre>";
print_r (hash_algos());
echo "</pre>";
?>
My output looks something like this:
Array
(
[0] => md2
[1] => md4
[2] => md5
...
)

- 101
- 1
- 6
-
3Please don't post links as answer, but explain the content of the link. What if the page is moved and someone is looking for that help ? – Cid Jun 08 '18 at 14:31
-
Thank you for the style guideline. I have updated my answer to address them, and I'll adhere to it going forward. – manno Jan 13 '20 at 04:34
-
Thanks...please upvote this answer for the future developer that will visit this page. – Syamsoul Azrien Apr 22 '20 at 07:25
PHP 5.3.2 added SHA-256 and SHA-512 to the crypt() function. This might be somewhat similar to what your looking for

- 566
- 4
- 15
-
Actually `password_hash()` is more secured than `crypt()`. I use password_hash with a strong salt to generate strong SHA-256 hashes. – Basit May 09 '14 at 07:28
-
1
-
@Basit-saeed - Your both right. password_hash() is more secure than crypt() but password_hash() is also a wrapper for crypt(). – Lionel Morrison Aug 12 '14 at 19:59