|
Description:
This script can generate a random password between a certain minimum and maximum length.
Usage: Text Source
$chars = "abcdefghijklmnopqrstuvwxyz.@$01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$lmin = 4;
$lmax = 10;
$pass;
$pass_len = 0;
$pass_len = rand($lmax) while ($pass_len < $lmin);
$pass.= (split(//, $chars))[rand(length $chars)] while (--$pass_len >= 0);
print "$pass";
The license for this recipe is available here.
Discussion:
The top section of the script has a "Configurable Parameters" section where variables can be specified and the script will work accordingly. Explanation of configurable parameters :
- $chars : the password will only contain letter from this set.
- $lmin : the password should be atleast this long.
- $lmax : the password should be atmost this long.
The flexibility has been provided as all password requirements are different and hence this is a bit more useful approach.
|