How to create an MD5 Hash in PHP

How to create an MD5 Hash in PHP

In this first blog post TheToolsWeb | Web Tools, I present to you in a simple and objective way of how create a MD5 Hash in PHP, first of all, a very simple way to create the hash is to use a tool made available by TheToolsWeb, totally free, Click Here to access.

As defined by Wikipedia , MD5 "The MD5 message synthesis algorithm is a widely hashed function used that produces a 128-bit hash value expressed in 32 characters. Although MD5 was initially designed to be used as a cryptographic hash function, it has been found to suffer from extensive vulnerabilities. It can still be used as a checksum to check data integrity, but only against unintended corruption. It remains suitable for other non-cryptographic purposes, for example, to determine the partition for a specific key in a partitioned database. ", therefore, if you need better encryption, I recommend other hashes.

Without further ado, below is the php code for generating an MD5 hash:

$initialValue = 'Text to be Encrypted';
$finalValue = md5($initialValue);
echo $finalValue;
// Answer will be 'a5abe6989d6b20da25512367ba0bfd34'

The code above is very simple:

  • $initialValue = "Text to be Encrypted" - Fill the variable with the text to be encrypted;
  • $finalValue = md5($initialValue) - Hash with the md5() command;
  • echo $finalValue - Displays the encrypted value;

Test it now and see how simple it is.

Share

Comments