ArchiveApril 2014

PHP Passwords with Character Arrays

P

Here’s a simple function I recently wrote to randomly generate passwords in PHP. //Generate new password $characterPool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_+=:;<>?'; $newPassword = ''; while(strlen($newPassword)<8) $newPassword .= $characterPool[mt_rand(0,strlen($characterPool)-1)]; Simplified a bit, this is equivalent to: //Generate new...

Chris Peterson

As a Web Application Developer & Elephant Trainer I have been putting the PHP mascot to work for more than a decade. I specialize in back-end development and use the LAMP stack to craft software that frees human beings to spend their time on more productive and rewarding things.

Recent Posts

Recent Comments

Archives