aboutsummaryrefslogtreecommitdiffstats
path: root/fripost-mkpass
blob: c0bf6de14965d14e8a2efcfd7fee3ecbc11c4a54 (plain)
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
#!/usr/bin/perl

use 5.010_000;
use warnings;
use strict;

=head1 NAME

fripost-mkpass - Create a random new password, and returns its hash

=head1 SYNOPSIS

B<fripost-mkpass> [I<password>]

=head1 DESCRIPTION

Use I<password> if given, otherwise generate a random new password, and
print both the clear copy and a salted SHA-1 hash.

=cut

use FindBin qw($Bin);
use lib "$Bin/lib";

our $VERSION = '0.01';

use Getopt::Long qw /:config noauto_abbrev no_ignore_case
                             gnu_compat bundling permute nogetopt_compat
                             auto_version auto_help/;
use Pod::Usage;
use Fripost::Password;

GetOptions( "man" => sub { pod2usage(-exitstatus => 0,
                                     -verbose => 2) }
    ) or pod2usage(2);

# Generate password
my $password = $ARGV[0];
$password //= mkpasswd();


# Show the information that will be inserted
say "Password:     " . $password;
say "Salted SHA-1: " . hash($password, SHA1, undef);

=head1 AUTHORS

Stefan Kangas C<< <skangas at skangas.se> >>

Guilhem Moulin C<< <guilhem at fripost.org> >>

=head1 COPYRIGHT

Copyright 2010,2011 Stefan Kangas.

Copyright 2012 Guilhem Moulin.

=head1 LICENSE

This program is free software; you can redistribute it and/or modify it
under the same terms as perl itself.

=cut