Move from mod_perl to being a PSGI app.
[pr0n] / perl / mkpasswd.pl
1 #! /usr/bin/perl
2
3
4 use lib qw(.);
5 use Term::ReadKey;
6 use strict;
7 use warnings;
8
9 use Sesse::pr0n::Config;
10 eval {
11         require Sesse::pr0n::Config_local;
12 };
13 use Sesse::pr0n::Common;
14
15 Term::ReadKey::ReadMode(2);
16 print STDERR "Enter password: ";
17 chomp (my $pass = <STDIN>);
18 print STDERR "\n";
19 Term::ReadKey::ReadMode(0);
20
21 my $salt = Sesse::pr0n::Common::get_pseudorandom_bytes(16);  # Doesn't need to be cryptographically secur.
22 my $hash = "\$2a\$07\$" . Crypt::Eksblowfish::Bcrypt::en_base64($salt);
23 print Crypt::Eksblowfish::Bcrypt::bcrypt($pass, $hash), "\n";
24