3
Recently I was looking for hash algorithms that were not known md5
, sha1
and sha2
, and that generate smaller hashs than those cited.
That’s when I found myself thinking, how can I know which hash algorithms are available for my use, in PHP?
3
Recently I was looking for hash algorithms that were not known md5
, sha1
and sha2
, and that generate smaller hashs than those cited.
That’s when I found myself thinking, how can I know which hash algorithms are available for my use, in PHP?
4
PHP already comes with a range of hash algorithms available for use, including it has a specific function to show which algorithms are available, the hash_algos()
.
When rotating this function, it will return a array
with all available methods, example:
print_r(hash_algos());
The above code would print the following:
Array
(
[0] => md4
[1] => md5
[2] => sha1
[3] => sha256
[4] => sha384
[5] => sha512
[6] => ripemd128
[7] => ripemd160
[8] => whirlpool
// ...
To use a specific algorithm you can use the function hash()
, example:
echo hash("crc32b", "minha-string");
// imprime: 5373ff38
Browser other questions tagged php hash
You are not signed in. Login or sign up in order to post.