How To Generate A Simple Random Password In PHP

How To Generate A Simple Random Password In PHP [Unbreakable]

By Anand Lagad   December 8, 2017 PHP
For creating the unbreakable and simple random password in PHP please read below points!

 

The password should be longer.  Longer the password harder to crack! You can consider 8 character size or more.

 

Avoid things such as the use of just names, places, favorite words, date of birth, personal phone number etc as a password.

 

Use a mixture of numbers, letters, uppercase and lowercase letters, special symbols etc.

EXAMPLE:

CREATING SIMPLE RANDOM PASSWORD IN PHP [UNBREAKABLE]

<?php
/*******
PROGRAM: Create a simple random password in PHP which will be unbreakable
******/

// STEP 1. Define the password length

$password_length=10;

// STEP 2. DEFINE AND CALL PASSOWRD GENERATOR FUNCTION

function unbreakable_password($pass_len=8)  // default value, if length is not provided

{

// all the characters which you want to use for password creation

$all_chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%abcdefghijklmnopqrstuvwxyz';

//shuffle all chars..

$shuffled_chars= str_shuffle( $all_chars);

//get first $pass_lennumber of characters from shuffled string as a password

$password = substr( $shuffled_chars, 0, $pass_len);

return $password;

}

echo $unbreakable_password=unbreakable_password($password_length);

?>

 

Hope this helped!

 

There are so many ways to generate such random passwords in PHP.

Please comment such ways.


Comments

  • error: Content is protected !!