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