Changeset 1151 for trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Utils.pm
- Timestamp:
- 09/19/12 17:22:52 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Utils.pm
r1124 r1151 8 8 use LATMOS::Accounts::Log; 9 9 use File::Temp qw(tempfile); 10 use Crypt::Cracklib; 10 11 11 12 our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; … … 247 248 } 248 249 250 =head2 genpassword 251 252 =cut 253 254 sub genpassword { 255 my (%options) = @_; 256 my @non_alpha = (qw$; : / ! ( ) [ ] { } + = @ - " ' % * & . ? < >$, ',', '$'); 257 my @letters = ('a' .. 'z', 'A' .. 'Z', 0 .. 9); 258 259 my @consonants = qw(b d f g j k l m n r s t v x z ch); 260 my @vowels = qw(a e i o u ou oi io ia iu); 261 262 $options{length} ||= 6 + int(rand(3)); 263 264 while (1) { 265 if ($options{syllables}) { 266 $options{length} = int($options{length} / 2); 267 $options{length} = 3 if ($options{length} < 3); 268 } else { 269 $options{length} = 6 if ($options{length} < 6); 270 } 271 272 my @chars; 273 274 if ($options{nonalpha}) { 275 for(0 .. (0 + int(rand(3)))) { 276 push(@chars, (@non_alpha[rand(scalar(@non_alpha))])); 277 } 278 } 279 280 foreach (1 .. ($options{length} - scalar(@chars))) { 281 if ($options{syllables}) { 282 my $c = @consonants[rand(scalar(@consonants))]; 283 my $v = @vowels[rand(scalar(@vowels))]; 284 push(@chars, "$c$v"); 285 } else { 286 push(@chars, (@letters[rand(scalar(@letters))])); 287 } 288 } 289 290 291 my $pass = join('', sort { rand() <=> rand() } @chars); 292 if (length($pass) >= 6 && fascist_check($pass) eq 'ok') { 293 return $pass; 294 } 295 } 296 } 297 249 298 1; 250 299
Note: See TracChangeset
for help on using the changeset viewer.