-Provide missing password generation function

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5519 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2010-03-18 14:02:12 +00:00
parent d6c6738c45
commit 55704f6c8d

View File

@ -615,4 +615,19 @@ sub sendmsg {
# waitforack($outfd);
$callback->($msg);
}
sub genpassword
{
#Generate a pseudo-random password of specified length
my $length = shift;
my $password = '';
my $characters =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890';
srand; #have to reseed, rand is not rand otherwise
while (length($password) < $length)
{
$password .= substr($characters, int(rand 63), 1);
}
return $password;
}
1;