00 Votes

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.

ReplyPositiveNegative

About the Author

AvatarThe author has not added a profile short description yet.
Show Profile

 

Related Topics

PHP: Upload of large Files

Tutorial | 0 Comments

VirtualBox: Change Date and Time

Tutorial | 10 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.