Loading...
 
Gmail / Facebook Style Chat Application


Posted: Sunday 30th of September 2012

How to check if a string is a valid md5 hash



This tutorial consist of a simple php function that will help you to check if a given string is a valid MD5 hash or not and that means, the given string has to be 32 characters in length and can only consist of letters and numbers.
For instance: To encrypt 123456 with MD5 hash will give you e10adc3949ba59abbe56e057f20f883e
Now test the above hashed with the function to see the result.

Code:

<?php
function MD5_Hashed_is_Valid($md5)
{
      return !empty($md5) && preg_match('/^[a-f0-9]{32}$/', $md5);
}

$MD5_Hashed = "e10adc3949ba59abbe56e057f20f883e";
if(MD5_Hashed_is_Valid($MD5_Hashed))
{
      echo "Your given MD5 Hashed string is valid.";
}
else
{
      echo "Sorry, your given MD5 Hashed string is not valid.";
}
?>




That's it guys...


Views Today: 0
Total Views: 1570

Comments
0
OUR OBJECTIVE

Our objective is to reach a place where our services will be highly regarded by businesses from various industrial domains for building their innovative busines solutions with our cutting-edge technological expertise, interactive designs and uncompromised quality.

OUR MISSION

We aspire to help businesses ranging from startups to enterprises, who reach out to us with their requirements, in achieving great lengths, expanding their reach, upscaling their products, and generate a large user-base with our outstanding and cost-effective services.

Copyright © 2011 - 2024 | All Rights Reserved