Friday, February 2, 2018

Password Generator In PHP

Password Generator In PHP Function . We can generate dynamic password with numeric, alphanumeric etc using php. I created dynamic_password function. It will generate and return the dynamic password. You should have to send password type, length like sha1, md5 for password type and numeric value for password length.


Here Is The Function

<?php
function dynamic_password($type='',$length=10){
  // Dynamic password function
  $chars = array_merge(range(0,9), range('a','z'), range('A','Z'));
  shuffle($chars);
  $password = implode(array_slice($chars, 0, $length));
  if($type=='md5'){
   $password=md5($password);
  }else if($type=='sha1'){
   $password=sha1($password);
  }
  return $password;
}
?>
Share:

0 comments:

Post a Comment

Popular Posts

Blog Archive