PHP/MySQL made simple:

Web development

Apr 14 2008   4:23PM GMT

Intelligent Password Generator (Part I)



Posted by: Jon Harris
Web development, PHP/MySQL

Outline
Everybody and their brother(or sister, as the case may be) has their own “random password generator”. I’ve used them, and to be honest, I’ve never been impressed. You wind up with these passwords that are impossible to remember with combinations that just don’t “flow” when you attempt to type them. I got to thinking about all the times that I’ve helped others figure out a good password. One that would meet our requirements *and* be easy to remember. This is an example of how it works:

“Yes, Mr. Doe, your email account was compromised, so we had to disable your account. When you’re ready to change your password, please give us a call at XXX-XXX-XXXX).”

“I’m ready to change it now, but I don’t know what to change it to. Could you help me pick a password?”

“Sure, I’ll tell you what. Think of your first pets name. Think of the day you were married, or had your first kid, and then think of another meaningful person or event, and change one letter to a symbol….”

“Ok, I got it, it’s Dog1935f@ther. That’s easy to remember!”

“Your first dogs name was ‘Dog’?”

“He was a fish….”

Ok, the last part was just comedy, but you get the gist. Only intelligent beings can make intelligent passwords, UNLESS….

Never mind. You aren’t interested anyways.

Oh, you are? Ok.

Basic Concept

I needed an application that would take a few words, a couple numbers, and a date. It would need to strip out any characters that I didn’t allow in my passwords, and it needed to be able to replace characters to make the password meet the combination requirements set my my site, for security reasons.

Broken down, it needed to

  • Take 3 words
  • take 1 number
  • Take 1 date, in any format

Then, it needed to:

  • Strip out any illegal characters
  • combine enough words to meet the password length requirements
  • substitute characters with similar characters until the password strength has been met
  • check the password, to verify that it meets all requirements
  • create 2 more passwords, and output to the customers screen

Next time:
I will give you a part of the code, and explain why I did it this way.
I will show you some examples of what this application will output when given different input.