How to Generate md5 hash in PHP

To Generate md5 hash in PHP is an easy task by the use of in built functions. Here I am writing an example code for generating md5 hash in PHP and You can embed this code in any PHP website or even your PHP blog. The md5 is one way hash method, mostly used for calculating checksum of texts or objects.

md5 is also popular,because of its use in UNIX/LINUX password storing, as  LINUX stores password in md5 hash of actual password given by user.

Here is a small web script in php for generate md5 hash from text.


<html>
<form action="" method="post">
<p>enter text here: <input type="text" name="t1" /></p>
<p><input type="submit" /></p>
</form>
<?php
//md5 generate script
$str = "deafult hash";
if(isset($_POST['t1']))
{
$str = $_POST['t1'];
}
echo "<BR>";
$md5 = md5($str);
echo "md5 hash of text is: <br><br>";
echo $md5;
//tested at skillsyard
?>
</html>

just write the text and save the file as md5.php

Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe

Subscribe to Khalsa Labs