PHP Code

Make a Random Password Generator with PHP

Sometimes you just want to use a different password that is more secure than what you normally use. It's not always easy to get that password. Dreaming one up typically means that you will use at least some portion of the password that is associated with something you know.

On the other hand, you may want to create an automatic registration system (such as in an e-commerce site) that automatically creates a random password the first time someone purchases something.

Creating a random password generator means that you can easily generate secure passwords on the fly. The code that you will be needing to accomplish that is listed below.

function password(length, special) {

var iteration = 0;
var password = \"\";
var randomNumber;
if(special == undefined){
var special = false;
}

while(iteration < length){ randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33; iteration++; password += String.fromCharCode(randomNumber); } return password; } // call it like this: echo password(10); [/code] Submit a comment if you have any problems with this code.

Share

Leave a Reply

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

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image