Some websites require access control, and sometimes you may need to generate a password for a user. Here’s a simple function that can do just that.
The $base-variable contains the characters allowed in the password. The supplied string may be changed, but the selected charaters should exist on all keyboards (as far as I know). When calling the function, you can specify the lenght of the password you want. Simple, right?
In the book “the Davinci Code” there was a fun little device called a cryptex.. A Cryptex has 6 dials with 6 letters on each, and only one combination producing a word will open it. The most straight forward way to crack it would be to try every combination one by one, but there’s a substantial number of combinations and we know only those which a valid words is a candidate.
A great strength in PHP is that it’s so accessible, that almost anyone can get access to a PHP site and often will download “applications” for their site such as discussion boards, photo galleries and others. While it may easy to download such applications, it often happens that the people trying to get things to work, doesn’t read the requirements section of the install.txt or readme.txt file, and thus never get the application running and doesn’t understand what the problem was and how to fix it.
We are a fairly large PHP shop at work running some of the largest Danish websites. In a fairly new project, it was suggested that we considered using the Zend Framework to fast track development and piggy back upon some of the components provided by the framework. We looked at it, and said no – at least for now. Since the Zend Framework website does an excellent sales pitch on why you should use it, here’s some of the arguments why you should restrain from using the framework.
Suppose you want to write a system, which requires a password to do something. Not a login system, but just a shared secret. Suppose also, that you need to show someone the source code, but you don’t want him or her, the secret password can you do that. Sure. Here’s a simple way to do it with PHP.