A collegue of mine was complaining to me that he had to create accounts for 750 people on a mix of Solaris and Linux systems where he works. And he had to do it within a couple of days.
Given that he had the names and account ids in a comma delimited file all he needed was to create the accounts and send the passwords to the account owners. But where in the world was he coming up with all those passwords?
Part of the issue was on one store for account information they use SALT encryption and on the other they use MD5 passwords.
This is by no means the only way to do it but it was something I whipped up in less than 20 minutes to solve the problem. Hope this may be of some service to the next person.
A lot of extra code was left out of this for clarity sake. Some of the logic I left out was:
#!/usr/bin/perl -w ###################################################################### +## use strict; use Tie::File; use Fcntl 'O_RDONLY'; use Digest::MD5 qw(md5_hex); use Data::Dumper; print Dumper(random_password()),"\n" foreach 0..4; exit(0); sub random_password { my @punct= qw/ ; : + = % $ ! . /; my $retval={}; my $word1 = select_a_word(); my $word2 = select_a_word(); my $plain_text= $word1 . $punct[rand($#punct)+1] . $word2; $retval->{plain_text}=$plain_text; $retval->{md5_hash} = md5_hex($plain_text); $retval->{crypt} = crypt($plain_text,pass_the_salt()); return $retval; } sub pass_the_salt { my @salt_lick = ( 'a'..'z' ); return $salt_lick[rand($#salt_lick)+1] . $salt_lick[rand($#salt_li +ck)+1]; } sub select_a_word { my @words=(); tie @words,"Tie::File","/usr/share/dict/linux.words",mode=>O_RDONL +Y or die $!; my $word = $words[rand($#words)]; $word =~ tr /A-Z/a-z/; untie @words; if (length($word) > 6 ) { return select_a_word(); } eles { return $word; } }
In reply to Creating random passwords for users. by blue_cowdawg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |