App-Genpass

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

        - Fix tests by requiring namespace::clean at least 0.2

2.00    17.02.11
        ** Major change **
        - Moving to Mouse instead of Moose. Should work much faster for users
          without causing problems.
          (since it's a big change, I'm noting this as a very major release)

1.01    18.07.10
        - Fixed small test bug, must return from default coderef
        - Explaining how much "speeds" noverify adds
        (0.1 secs for 500 passwords of 500 char length)

1.00    17.07.10
        [API Change]
        - renamed "repeat" (-r) to "number" (-n)
        - renamed -e to -r.

        [Docs]
        - Document default configuration files

README  view on Meta::CPAN


      Use only readable characters, excluding confusing characters: "o",
      "O", "0", "l", "1", "I", and special characters such as '#', '!', '%'
      and other symbols.

      You can overwrite what characters are considered unreadable under
      "character attributes" below.

      Default: on.

    verify

      Verify that every type of character wanted (lowercase, uppercase,
      numerical, specials, etc.) are present in the password. This makes it
      just a tad slower, but it guarantees the result. Best keep it on.

      To emphasize how "slower" it is: if you create 500 passwords of 500
      character length, using verify off, will make it faster by 0.1
      seconds.

      Default: on.

  attributes

    minlength

      The minimum length of password to generate.

bin/genpass  view on Meta::CPAN

=head1 SYNOPSIS

genpass [-rlnsv] [long options...]

 Options:
          --configfile      configuration file to read (YAML, JSON, INI, etc.)
    -r    --readable        create readable passwords
    -l    --length          password length
    -n    --number          how many passwords to create
    -s    --special         use special characters (clashes with readable opt)
    -v    --verify          verify types of characters
          --lowercase       what lowercase characters to use
          --uppercase       what uppercase characters to use
          --numerical       what numerical characters to use
          --specials        what characters are considered special
          --unreadable      what characters are considered unreadable
          --usage           brief usage output
          --help            what you're currently reading

=head1 DESCRIPTION

bin/genpass  view on Meta::CPAN

such as period, exclamation mark, percentage sign, etc.

    genpass --special

You can negate this flag by doing:

    genpass --nospecial

Default: no.

=item B<-v | --verify>

Whether to verify that the variety of characters you requested is included.

Disabling this gains you speed if you create a rather large number of passwords
that have a rather large number of characters. Then you don't need to worry as
much about having that variety since probability says you probably will.

You can negate this using:

    genpass --noverify

Best to keep it on though.

Default: yes.

=item B<--lowercase>

Which characters are considered lowercase?

=item B<--uppercase>

lib/App/Genpass.pm  view on Meta::CPAN

    isa     => Int,
    default => quote_sub( q{1} ),
);

has readable => (
    is      => 'ro',
    isa     => Bool,
    default => quote_sub( q{1} ),
);

has verify => (
    is      => 'ro',
    isa     => Bool,
    default => quote_sub( q{1} ),
);

has length => (
    is  => 'ro',
    isa => Int,
);

lib/App/Genpass.pm  view on Meta::CPAN


    GetOptions(
        'configfile=s'  => \$opts{'configfile'},
        'lowercase=s@'  => \$opts{'lowercase'},
        'uppercase=s@'  => \$opts{'uppercase'},
        'numerical=i@'  => \$opts{'numerical'},
        'unreadable=s@' => \$opts{'unreadable'},
        'specials=s@'   => \$opts{'specials'},
        'n|number=i'    => \$opts{'number'},
        'r|readable!'   => \$opts{'readable'},
        'v|verify!'     => \$opts{'verify'},
        'l|length=i'    => \$opts{'length'},
        'm|minlength=i' => \$opts{'minlength'},
        'x|maxlength=i' => \$opts{'maxlength'},
    ) or croak q{Can't get options.};

    # remove undefined keys
    foreach my $key ( keys %opts ) {
        defined $opts{$key} or delete $opts{$key};
    }

lib/App/Genpass.pm  view on Meta::CPAN

    }

    # make both refs
    return [ \@types, @chars ];
}

sub generate {
    my ( $self, $number ) = @_;

    my $length;
    my $verify        = $self->verify;
    my @passwords     = ();
    my @verifications = ();
    my $EMPTY         = q{};

    my ( $char_types, @chars ) = @{ $self->_get_chars };

    my @char_types   = @{$char_types};
    my $num_of_types = scalar @char_types;

    if ( (defined($self->length) && $num_of_types > $self->length)

lib/App/Genpass.pm  view on Meta::CPAN


    # each password iteration needed
    foreach my $pass_iter ( 1 .. $number ) {
        my $password  = $EMPTY;
        my $char_type = shift @char_types;

        # generating the password
        while ( $length > length $password ) {
            my $char = $chars[ int _rand @chars ];

            # for verifying, we just check that it has small capital letters
            # if that doesn't work, we keep asking it to get a new random one
            # the check if it has large capital letters and so on
            if ( $verify && $char_type && @{ $self->$char_type } ) {
                # verify $char_type
                if ( @{ $self->$char_type } ) {
                    while ( ! any { $_ eq $char } @{ $self->$char_type } ) {
                        $char = $chars[ int _rand @chars ];
                    }
                }

                $char_type =
                    scalar @char_types > 0 ? shift @char_types : $EMPTY;
            }

lib/App/Genpass.pm  view on Meta::CPAN

=item readable

Use only readable characters, excluding confusing characters: "o", "O", "0",
"l", "1", "I", and special characters such as '#', '!', '%' and other symbols.

You can overwrite what characters are considered unreadable under "character
attributes" below.

Default: on.

=item verify

Verify that every type of character wanted (lowercase, uppercase, numerical,
specials, etc.) are present in the password. This makes it just a tad slower,
but it guarantees the result. Best keep it on.

To emphasize how "slower" it is: if you create 500 passwords of 500 character
length, using C<verify> off, will make it faster by 0.1 seconds.

Default: on.

=back

=head3 attributes

=over 4

=item minlength



( run in 0.248 second using v1.01-cache-2.11-cpan-73692580452 )