Calculate Hash using PHP
Info by Axuter | 2012-06-26 at 16:26
Many do not know, that with PHP, you can also calculate other hashes than MD5 and CRC32. For MD5 and CRC32 as well as for some other hash values, there are separate functions such as md5() and crc32(). For many other hashes, there is the function hash() which can be called like this:
$string = 'We are calculating the hash of this string.'; echo hash('md5', $string); echo hash('adler32', $string);
The function knows the following paramaters to calculate the different hashes:
- adler32
- crc32, crc32b
- gost
- haval128,3, haval160,3, haval192,3, haval224,3, haval256,3
- haval128,4, haval160,4, haval192,4, haval224,4, haval256,4
- haval128,5, haval160,5, haval192,5, haval224,5, haval256,5
- md2, md4, md5
- ripemd128, ripemd160, ripemd256, ripemd320
- salsa10, salsa20
- sha1, sha224, sha256, sha384, sha512
- snefru, snefru256
- tiger128,3, tiger160,3, tiger192,3
- tiger128,4, tiger160,4, tiger192,4
- whirpool
The function hash () is part of version 5 of PHP. For older versions of PHP, you can use the mhash extension, with which you can also calculate the hash.
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
PHP: Difference between hash and mhash
Question | 1 Answer
PHP: Upload of large Files
Tutorial | 0 Comments
PHP: Check Strings with Ctype-Functions for Character Classes
Article | 0 Comments
JavaScript: Sort array of numbers
Tutorial | 0 Comments
HTML: Difference between ID and CLASS
Info | 0 Comments
Color Values: Convert RGB, CMYK, CMY, HSV, TColor and XYZ Values
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.