Password generator: Difference between revisions

Content added Content deleted
Line 3,083:
sub char-groups( @exclude )
{
mystate %@char-groups =
lc => ['a' .. 'z'],
uc => ['A' .. 'Z'],
digit => ['0' .. '9'],
special => < $ % & \ ` ~ ! * + , - . / : ; = ? @ ^ _ ~ [ ] ( ) { | } # ' " \< \> >;
 
for %@char-groups.keys
.map( * (-) @exclude )
{
.grep( *.so );
%char-groups{ $_ } = %char-groups{ $_ } (-) @exclude;
%char-groups{ $_ }:delete unless %char-groups{ $_ };
}
 
%char-groups;
}
 
sub generate-passwords( UInt $count, UInt $length, %@char-groups )
{
password-characters( %@char-groups )
.batch( $length )
.map( *.pick: Inf ) # shuffle, so we don't get a predictable pattern
Line 3,107 ⟶ 3,103:
}
 
sub password-characters( %@char-groups )
{
gather loop { take .pick for @char-groups }
take %char-groups{ .key }.pick for %char-groups
};
}