News for hackers. Stuff that matters.

One-liner password generation in PHP

How would you improve this one-liner?

$password = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$'),0 , 10);

( 4 comments | 2 points | on HN )
Re:One-liner password generation in PHP by murrain on Saturday January 19, 2013 @10:52AM (#5083690)
$password = str_shuffle((substr(str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZ'),0,3).substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'),0,3).substr(str_shuffle('0123456789'),0,2).substr(str_shuffle('!@#$'),0,2)));
Re:One-liner password generation in PHP by murrain on Saturday January 19, 2013 @10:52AM (#5083691)
With that it will always contain 3 capital letters, 3 lower case letters, 2 numbers, and 2 punctuation.
Re:One-liner password generation in PHP by stevekemp on Saturday January 19, 2013 @06:53PM (#5085324)
I would remove "i"/"I", or 1. I would similarly remove one of zero and the letter-o.

These can be confusing to people, depending on fonts.

Re:One-liner password generation in PHP by kappaloris on Saturday January 19, 2013 @10:19AM (#5083595)
variable length maybe