Alex Barylo on Thu, 2 Mar 2000 11:16:38 -0500 (EST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Generate a password


Thank you guys for the ideas!

Here's what I ended up with:

====================== CUT HERE ======================
open WORDS, '/usr/dict/words' or die "Cannot open words file: $!\n";
my @WORDS = <WORDS>;
chomp @WORDS;
close WORDS;
srand;      # Yes, I know, I know it is not necessary any more.

[snip]

sub create_pass {
  my (@chars, $pass) = (split //, '~`!@#$%^&*()_+-=[]{}\;:\'",.<>/?');

  # 8 chars is the limit
  $pass = get_word(3) . $chars[rand @chars] .
          get_word(3) . $chars[rand @chars];
  return $pass, crypt($pass, get_word(2));
}

sub get_word {
  my ($len, $word) = shift;
  # Yeah, I HAD to add this - I don't wanna problems with users
  my $bad_choice = 'ass|sex|gay|wet';	# what else?
  while (length($word = @WORDS[rand @WORDS]) != $len or $word =~ /$bad_choice/o) {};
  randcap($word);
}

sub randcap {
  my $w = shift;
  ($w, ucfirst $w, uc $w, scalar reverse ucfirst reverse $w)[rand 4];
}
====================== CUT HERE ======================

I got some funny passwords (don't remember the case): bar:foo#,
dec@out', his\ear$, etc. And some potentially dangerous: roy`ass&,
air\sex<, etc. So I added $bad_choice.

One more question. If I create a password using passwd utility
encrypted password in /etc/shadow on my RH 6.1 is 34 chars long.
Although my newly created by Perl's crypt() 13 char password works as
well. Does anyone have any ideas which call creates such (34 char)
password?

Alex.
--------
Before the accident, I could not even spell UNIX

**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**