/dev/random for password generation

This commit is contained in:
Denis Zheleztsov 2015-04-10 10:05:45 +03:00
parent 82132b87be
commit 9920557fef

View File

@ -136,9 +136,17 @@ sub save {
# Generate password # Generate password
sub generate { sub generate {
my @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, '!', '@', '$', '(', ')' ); my $value;
open my $rnd, "<", "/dev/random";
read $rnd, $value, 32;
my $c = unpack ("H*", $value);
my @chars = split(//,$c);
push @chars, $_ for ( '!', '@', '(', ')','A'..'Z' );
my $string; my $string;
$string .= $chars[ rand @chars ] for 1 .. 16; $string .= $chars[ rand @chars ] for 1 .. 16;
return $string; return $string;
} }