

One-liner password generation in PHP - sgarbi

How would you improve this one-liner?<p>$password = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$'),0 , 10);
======
murrain
$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)));

~~~
murrain
With that it will always contain 3 capital letters, 3 lower case letters, 2
numbers, and 2 punctuation.

------
stevekemp
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.

------
kappaloris
variable length maybe

