File: zxcvbn-password-strength

package info (click to toggle)
libdata-password-zxcvbn-perl 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,564 kB
  • sloc: perl: 100,726; makefile: 9
file content (112 lines) | stat: -rw-r--r-- 2,164 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Password::zxcvbn;
use Getopt::Long qw(:config
                    posix_default no_require_order
                    auto_version auto_help
               );
our $VERSION = '1.1.2'; # VERSION
# PODNAME: zxcvbn-password-strength
# ABSTRACT: evaluate password strength


my ($json,@from);
GetOptions(
    'json|j!' => \$json,
    'from|f=s' => \@from,
);

if ($json) {
    require JSON::MaybeXS;
    $json = JSON::MaybeXS->new(
        ascii => 1,
        pretty => 1,
        canonical => 1,
        allow_blessed => 1,
        convert_blessed => 1,
    );
}

sub check_one {
    my ($password) = @_;
    my $strength = Data::Password::zxcvbn::password_strength($password);
    if ($json) {
        print $json->encode({
            password => $password,
            strength => $strength,
        }),",\n";
    }
    else {
        print $password, ' -> ',$strength->{score},"\n";
    };
}

check_one($_) for @ARGV;
for my $file (@from) {
    open my $fh,'<:utf8',$file or die "Can't open $file: $!";
    while (my $password = <$fh>) {
        chomp $password;
        next unless $password;
        check_one($password);
    }
}

__END__

=pod

=encoding UTF-8

=head1 NAME

zxcvbn-password-strength - evaluate password strength

=head1 VERSION

version 1.1.2

=head1 SYNOPSIS

  zxcvbn-password-strength [options] [password...]

Options:

=over 4

=item C<--json>

=item C<-j>

output a stream of JSON objects with full details for each password;
without this option, only the password and its score will be printed

=item C<< --from <file> >>

=item C<< -f <file> >>

opens the given C<file> and treats each line as a password to
evaluate; can be given more than once

=item C<--help>

prints this help message and exits

=item C<--version>

prints the script version and exits

=back

=head1 AUTHOR

Gianni Ceccarelli <gianni.ceccarelli@broadbean.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by BroadBean UK, a CareerBuilder Company.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut