#!/usr/bin/perl print "Content-type:text/html\n\n"; $passwd = random_password(); print "Your random password is $passwd.
\n"; sub random_password { # Generate a random password. Alternates vowels and # consonants, for maximum pronounceability. Uses its own # list of consonants which exclude F and C and K to prevent # generating obscene-sounding passwords. Capital I and # lowercase L are excluded on the basis of looking like #each other. ($length) = @_; if ($length eq "" or $length < 3) { $length = 6; # make it at least 6 chars long. } $vowels = "aeiouyAEUY"; $consonants = "bdghjmnpqrstvwxzBDGHJLMNPQRSTVWXZ12345678"; srand(time() ^ ($$ + ($$ << 15)) ); $alt = int(rand(2)) - 1; $s = ""; $newchar = ""; foreach $i (0..$length-1) { if ($alt == 1) { $newchar = substr($vowels,rand(length($vowels)),1); } else { $newchar = substr($consonants, rand(length($consonants)),1); } $s .= $newchar; $alt = !$alt; } return $s; }