April 14, 2008 4:23 PM
Posted by: Jonsjava
, Web development
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.
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
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.
April 11, 2008 3:25 PM
Posted by: Jonsjava
There are many sites out there that offer a good list of software to help you program PHP, as well as a good number of websites that help you out with a project by linking you to great open-source products that server a purpose. This will not be one of those sites. This site will be for those of you who already have your program of choice, be it a $500.00 IDE or just notepad, but you need pointers on how to do something, and can’t find a good place to get the info.
I started programming in PHP because, well, I needed some money. Since then, I have become fairly proficient in the language. You will almost never see me write Object-Oriented (O-O) scripts, and rarely use case statements. That doesn’t mean that I don’t know how, it simply means that I prefer the style I use. There are many ways to write a PHP program, and some are better than others. What I am going to be offering for you is the basic idea for code, and a working sample, with a good explanation on how it works, as well as why I do it that way. Hopefully I will show you good ways to program, as well as open you up to the possibility to the fact that there are other ways to program other than Object oriented programming.
The first example I will use is a fun one. There is a site, 99 bottles of beer.net, who’s goal is to have a repository of programming source code that when executed will generate the full song “99 Bottles of Beer on the Wall“. Most people will use a class that will return the value of the bottle until you reach 0, then print the final line:
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
I don’t like wasting code. I’m a firm believer that programmers have more important things to do than write useless lines of code, when just a few, short lines will do. My solution to this challenge? This:
*EDIT*Could not leave script in and keep rest of post looking correct. to view code, go to http://vent.jonsjava.com/beer.txt
What this script does is this:
- sets the max number of beers ($count=99)
- prints out each verse until it reaches zero, decreasing the number of bottles each time (–$count)
- Once it reaches zero, it prints the final verse, then it’s done
(To see the code in action, go to http://vent.jonsjava.com/beer.php
Do you really need a 75-line class to do this? It may not be pretty, but it’s a good proof of concept.
In the Next Issue
I will be discussing how to write an intelligent password generator