Generate random Password for Website,Web Application and the Web apps in PHP

Random Password Generator

Sometimes, We need to Generate Random Password for the Websites or the Web Application. And There Are Many Ways to Generate Password Randomly.Here Show How to Generate Random Password Using Simple Function.

Script For Generate Password: 


1
2
3
4
5
6
7
<?php
function random_password($length) {
    $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
    $password = substr( str_shuffle( $chars ), 0, $length );
    return $password;
}
?>

In This code Use the  str_shuffle  String Function To Generate the Random Password .Here is The code for how to run function to Get the output of function.


1
2
3
<?php
echo random_password(8);
?>

In This code What ever Length You Want for Password Just Replace in function's Argument.If You Want Password length 10 Just Replace on 8 to 10.


Previous
Next Post »

1 comments:

Write comments
Knowledge Hub
AUTHOR
9 April 2016 at 04:30 delete

Nice one...Dude..!!:-bd

Reply
avatar