Random Password Generator in PHP

Source code :

<?php
function password($pass) 
{
  $input = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz!@#$%^&*(){}<>?,./';
  return substr(str_shuffle($input), 0, $pass);
}
  echo password(10);

Output :

oOyU#6b08P

Notes :

substr(string,start,length) picks the string from the shuffled input string with the defined length in the syntax.

Algorithm :

  1. Initialize the possible input characters/integers/symbols.
  2. Shuffle the string.
  3. Print the string with definite length

Output :


                

Comments :