how to encrypt password in php - Web Development and Web Design Codes

Latest

Tuesday, February 20, 2018

how to encrypt password in php

how to encrypt password in php

how to encrypt password in php
how to encrypt password in php
Hi Friends today we are going to learn how to encrypt password in php..in this lesson we will learn about MD5 encryption and SHA1 encryption ..
Just follow the below php password encryption examples:

1. MD5 encryption :
$string="12345";
$pass=md5($string);
echo $pass;
Try this MD5 encryption example..

2. SHA1 encryption Example:
$string='12345';
$pass=SHA1($string);
echo $pass;

Try This SHA1 encryption example..

Now Create MD5 and SHA1 encryption generator..
<h2>PHP MD5,SHA1 Password Hashing</h2>
<form method="POST" action="">
  <table>
     <tr>
     <td>Your Password</td>
  <td><input type="text" name="password"/></td>
  </tr>
  <tr>
     <td></td>
  <td><input type="submit" name="submit" value="MD5"/>||
  <input type="submit" name="submit" value="SHA1"/>||
  <input type="submit" name="submit" value="BOTH"/>
  
  </td>
  </tr>
  </table>
</form>
<?php
if(isset($_POST['submit'])){
 if(!empty($_POST['password'])){
 $pass=$_POST['password'];
 if($_POST['submit']=='MD5'){
  $password='<b>Your Orginal Password:</b>'.$pass.'<b> <br/>MD5 Password : </b>'.MD5($pass);
 }
 if($_POST['submit']=='SHA1'){
  $password='<b>Your Orginal Password:</b>'.$pass.'<b> <br/>SHA1 Password : </b>'.SHA1($pass);
 }
 if($_POST['submit']=='BOTH'){
     $password='<b>Your Orginal password: </b>'.$pass .'<br/><b>
  MD5:</b> '.MD5($pass).'<br/><b>SHA1: </b>'.SHA1($pass);
  }
 }else{
  echo "<b style=color:red>Your Password Can not be Empty</b>";
 }
}
?>
<?php
if(isset($password)){
 echo '<font style=color:green size=4>'.$password.'</font>';
}
?>

That's it Friends how to encrypt password in php..keep visiting this blog for more codes and examples ..Thank You..

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.