Free and Opensource software review, Operating system review, Tips and Tricks, System tweaks, troubleshooting, Tools and Techniques, Hacks

Generate Random Password using php

password securityA tough password is a key component to secure online accounts and other services that require password authentication. You must be very careful while choosing your password since in most cases it is the only key that protects your privacy or your personal data or your business. In most cases we choose a password by relating to something which we commonly use. This makes it easier for the hacker to guess your passwords. That is where we require a random password which have no relation to any of our common surroundings.

Thus choosing a random password manually will be very difficult since in some way it can get some similarity to our common surroundings. This is where a simple tool to generate random password which generates random password with no relation to its user becomes relevant. Here is how you can generate random password using a simple php script.

The main function used here is the rand() function in php which selects random value within a specified range.

A simple script to generate an 8 character random password is shown below.

$chars = “abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789″;
$pass = array();
$charLength = strlen($chars) – 1;
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $charLength);
$pass[] = $char[$n];
echo implode($pass);

Now lets see how the above script works.

random password generatio in php algorithm

The above script can be used where ever you have to provide a suggestion of password. The characters chosen here is not related to each other in any way making it very hard to guess. The above script is only an example, it is better to have more characters in the password to have better security. It can also slow down the hacker from brute forcing into your accounts.

The major disadvantage of using such a script to generate your password is that it will be impossible to remember it. You will have to write it down some where or should have a copy of this password somewhere so that you can access it when needed.

, , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>