/dev/random for password generation
This commit is contained in:
parent
82132b87be
commit
9920557fef
10
Password.pm
10
Password.pm
@ -136,7 +136,15 @@ sub save {
|
||||
|
||||
# Generate password
|
||||
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;
|
||||
$string .= $chars[ rand @chars ] for 1 .. 16;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user