Browse Source

added script to generate and compare passphrases

Issue #1

mostly for testing and seeding
master
Blaine Motsinger 1 year ago
parent
commit
88c8469c11
1 changed files with 36 additions and 0 deletions
  1. 36
    0
      scripts/generate_password.pl

+ 36
- 0
scripts/generate_password.pl View File

@@ -0,0 +1,36 @@
#!/usr/bin/perl

use Dancer2;
use Dancer2::Plugin::Passphrase;

use Getopt::Long;

my ( $passphrase );
GetOptions (
'passphrase=s' => \$passphrase,
);

my ( $pass, $store ) = ( $passphrase ? generate( $passphrase ) : generate() );
print 'passphrase: ' . $pass . "\n";
print 'encrypted: ' . $store . "\n";

print 'comparison: ' .
( compare( $pass, $store ) ? 'matches' : 'doesnt match' ) .
"\n";

sub generate {
my $pass = shift;
$pass ||= passphrase->generate_random( {
length => 32,
charset => [ 'a'..'z', 'A'..'Z', '0'..'9' ]
} );
my $store = passphrase( $pass )->generate->rfc2307;

return $pass, $store;
}

sub compare {
my ( $pass, $store ) = @_;

return passphrase( $pass )->matches( $store );
}

Loading…
Cancel
Save