App-Genpass-WordList
view release on metacpan or search on metacpan
script/genpass-wordlist view on Meta::CPAN
#!perl
### code_after_shebang
# Note: This script is a CLI for Riap function /App/Genpass/WordList/genpass
# and generated automatically using Perinci::CmdLine::Gen version 0.483
# PERICMD_INLINE_SCRIPT: {"code_after_shebang":"...","config_dirs":null,"config_filename":"genpass-wordlist.conf","env_name":"GENPASS_WORDLIST_OPT","include":null,"log":null,"pack_deps":1,"pod":0,"read_config":1,"read_env":1,"script_name":"genpass-wo...
my $_pci_metas = {""=>{args=>{num=>{cmdline_aliases=>{n=>{}},default=>1,schema=>["int",{min=>1,req=>1},{}]},patterns=>{cmdline_aliases=>{p=>{}},default=>["%w %w %w","%w %w %w %w","%w %w %w %w %w","%w %w %w %w %w %w","%W%4d%W","%W%6d%s"],description=>...
# This script is generated by Perinci::CmdLine::Inline version 0.541 on Tue Jan 2 11:22:14 2018.
# Rinci metadata taken from these modules: App::Genpass::WordList (no version)
# You probably should not manually edit this file.
our $DATE = '2018-01-02'; # DATE
our $VERSION = '0.002'; # VERSION
# PODNAME: genpass-wordlist
# ABSTRACT: Generate password with words from WordList::*
# BEGIN DATAPACK CODE
{
my $toc;
my $data_linepos = 1;
unshift @INC, sub {
$toc ||= do {
my $fh = \*DATA;
my $header_line;
my $header_found;
while (1) {
my $header_line = <$fh>;
defined($header_line)
or die "Unexpected end of data section while reading header line";
chomp($header_line);
if ($header_line eq 'Data::Section::Seekable v1') {
$header_found++;
last;
}
}
die "Can't find header 'Data::Section::Seekable v1'"
unless $header_found;
my %toc;
my $i = 0;
while (1) {
$i++;
my $toc_line = <$fh>;
defined($toc_line)
or die "Unexpected end of data section while reading TOC line #$i";
chomp($toc_line);
$toc_line =~ /\S/ or last;
$toc_line =~ /^([^,]+),(\d+),(\d+)(?:,(.*))?$/
or die "Invalid TOC line #$i in data section: $toc_line";
$toc{$1} = [$2, $3, $4];
}
my $pos = tell $fh;
$toc{$_}[0] += $pos for keys %toc;
# calculate the line number of data section
my $data_pos = tell(DATA);
seek DATA, 0, 0;
my $pos = 0;
while (1) {
my $line = <DATA>;
$pos += length($line);
$data_linepos++;
last if $pos >= $data_pos;
}
seek DATA, $data_pos, 0;
\%toc;
};
if ($toc->{$_[1]}) {
seek DATA, $toc->{$_[1]}[0], 0;
read DATA, my($content), $toc->{$_[1]}[1];
my ($order, $lineoffset) = split(';', $toc->{$_[1]}[2]);
$content =~ s/^#//gm;
$content = "# line ".($data_linepos + $order+1 + $lineoffset)." \"".__FILE__."\"\n" . $content;
open my $fh, '<', \$content
or die "DataPacker error loading $_[1]: $!";
return $fh;
}
return;
};
}
# END DATAPACK CODE
package main;
use 5.010001;
use strict;
#use warnings;
# modules
### declare global variables
our $_pci_meta_result_stream = 0;
our $_pci_meta_result_type;
our $_pci_meta_result_type_is_simple;
our $_pci_meta_skip_format = 0;
our $_pci_r = {naked_res=>0,read_config=>1,read_env=>1,subcommand_name=>""};
our %_pci_args;
### declare subroutines
sub _pci_err {
my $res = shift;
print STDERR "ERROR $res->[0]: $res->[1]\n";
exit $res->[0]-300;
}
sub _pci_json {
state $json = do {
if (eval { require JSON::XS; 1 }) { JSON::XS->new->canonical(1)->allow_nonref }
else { require JSON::PP; JSON::PP->new->canonical(1)->allow_nonref }
};
$json;
}
### get arguments (from config file, env, command-line args
{
my %mentioned_args;
require Getopt::Long::EvenLess;
my $go_spec1 = {
'config-path=s@' => sub { $_pci_r->{config_paths} //= []; push @{ $_pci_r->{config_paths} }, $_[1]; },
'config-profile=s' => sub { $_pci_r->{config_profile} = $_[1]; },
'format=s' => sub { $_pci_r->{format} = $_[1]; },
'help|h|?' => sub { print "genpass-wordlist - Generate password with words from WordList::*\n\nUsage:\n genpass-wordlist --help (or -h, -?)\n genpass-wordlist --version (or -v)\n genpass-wordlist [options]\n\nUsing password from dictionary wor...
'json' => sub { $_pci_r->{format} = (-t STDOUT) ? "json-pretty" : "json"; },
'naked-res' => sub { $_pci_r->{naked_res} = 1; },
'no-config' => sub { $_pci_r->{read_config} = 0; },
'no-env' => sub { $_pci_r->{read_env} = 0; },
'no-naked-res|nonaked-res' => sub { $_pci_r->{naked_res} = 0; },
'version|v' => sub { no warnings 'once'; require App::Genpass::WordList; print "genpass-wordlist version ", "0.002", ($App::Genpass::WordList::DATE ? " ($App::Genpass::WordList::DATE)" : ''), "\n"; print " Generated by Perinci::CmdLine::Inline v...
};
my $go_spec2 = {
'config-path=s@' => sub { },
'config-profile=s' => sub { },
'format=s' => sub { },
'help|h|?' => sub { },
'json' => sub { },
'n=s' => sub { $_pci_args{'num'} = $_[1];
},
'naked-res' => sub { },
'no-config' => sub { },
'no-env' => sub { },
'no-naked-res|nonaked-res' => sub { },
'num=s' => sub { $_pci_args{'num'} = $_[1];
},
'p=s@' => sub { if ($mentioned_args{'patterns'}++) { push @{ $_pci_args{'patterns'} }, $_[1] } else { $_pci_args{'patterns'} = [$_[1]] }
},
'pattern=s@' => sub { if ($mentioned_args{'patterns'}++) { push @{ $_pci_args{'patterns'} }, $_[1] } else { $_pci_args{'patterns'} = [$_[1]] }
},
'patterns-json=s' => sub { $_pci_args{'patterns'} = _pci_json()->decode($_[1]);
},
'version|v' => sub { },
'w=s@' => sub { if ($mentioned_args{'wordlists'}++) { push @{ $_pci_args{'wordlists'} }, $_[1] } else { $_pci_args{'wordlists'} = [$_[1]] }
},
'wordlist=s@' => sub { if ($mentioned_args{'wordlists'}++) { push @{ $_pci_args{'wordlists'} }, $_[1] } else { $_pci_args{'wordlists'} = [$_[1]] }
},
'wordlists-json=s' => sub { $_pci_args{'wordlists'} = _pci_json()->decode($_[1]);
},
};
my $old_conf = Getopt::Long::EvenLess::Configure("pass_through");
Getopt::Long::EvenLess::GetOptions(%$go_spec1);
Getopt::Long::EvenLess::Configure($old_conf);
{
last unless $_pci_r->{read_env};
my $env = $ENV{"GENPASS_WORDLIST_OPT"};
last unless defined $env;
require Complete::Bash;
my ($words, undef) = @{ Complete::Bash::parse_cmdline($env, 0) };
unshift @ARGV, @$words;
}
if ($_pci_r->{read_config}) {
require Perinci::CmdLine::Util::Config;
my $res = Perinci::CmdLine::Util::Config::read_config(
config_paths => $_pci_r->{config_paths},
config_filename => "genpass-wordlist.conf",
config_dirs => undef // ["$ENV{HOME}/.config", $ENV{HOME}, "/etc"],
program_name => "genpass-wordlist",
);
_pci_err($res) unless $res->[0] == 200;
$_pci_r->{config} = $res->[2];
$_pci_r->{read_config_files} = $res->[3]{"func.read_files"};
$_pci_r->{_config_section_read_order} = $res->[3]{"func.section_read_order"}; # we currently dont want to publish this request key
script/genpass-wordlist view on Meta::CPAN
}
my $res = Getopt::Long::EvenLess::GetOptions(%$go_spec2);
_pci_err([500, "GetOptions failed"]) unless $res;
}
### check arguments
{
require Local::_pci_check_args; my $res = _pci_check_args(\%_pci_args);
_pci_err($res) if $res->[0] != 200;
$_pci_r->{args} = \%_pci_args;
}
### call function
{
my $sc_name = $_pci_r->{subcommand_name};
if ($sc_name eq "") {
$_pci_meta_result_type = "";
require App::Genpass::WordList;
eval { $_pci_r->{res} = App::Genpass::WordList::genpass(%_pci_args) };
if ($@) { $_pci_r->{res} = [500, "Function died: $@"] }
}
}
### format & display result
{
my $fres;
my $save_res; if (exists $_pci_r->{res}[3]{"cmdline.result"}) { $save_res = $_pci_r->{res}[2]; $_pci_r->{res}[2] = $_pci_r->{res}[3]{"cmdline.result"} }
my $is_success = $_pci_r->{res}[0] =~ /\A2/ || $_pci_r->{res}[0] == 304;
my $is_stream = $_pci_r->{res}[3]{stream} // $_pci_meta_result_stream // 0;
if ($is_success && (0 || $_pci_meta_skip_format || $_pci_r->{res}[3]{"cmdline.skip_format"})) { $fres = $_pci_r->{res}[2] }
elsif ($is_success && $is_stream) {}
else { require Local::_pci_clean_json; require Perinci::Result::Format::Lite; $is_stream=0; _pci_clean_json($_pci_r->{res}); $fres = Perinci::Result::Format::Lite::format($_pci_r->{res}, ($_pci_r->{format} // $_pci_r->{res}[3]{"cmdline.default_format...
my $use_utf8 = $_pci_r->{res}[3]{"x.hint.result_binary"} ? 0 : 1;
if ($use_utf8) { binmode STDOUT, ":encoding(utf8)" }
if ($is_stream) {
my $code = $_pci_r->{res}[2]; if (ref($code) ne "CODE") { die "Result is a stream but no coderef provided" } if ($_pci_meta_result_type_is_simple) { while(defined(my $l=$code->())) { print $l; print "\n" unless $_pci_meta_result_type eq "buf"; } ...
} else {
print $fres;
}
if (defined $save_res) { $_pci_r->{res}[2] = $save_res }
}
### exit
{
my $status = $_pci_r->{res}[0];
my $exit_code = $_pci_r->{res}[3]{"cmdline.exit_code"} // ($status =~ /200|304/ ? 0 : ($status-300));
exit($exit_code);
}
=pod
=encoding UTF-8
=head1 NAME
genpass-wordlist - Generate password with words from WordList::*
=head1 VERSION
This document describes version 0.002 of main (from Perl distribution App-Genpass-WordList), released on 2018-01-02.
=head1 SYNOPSIS
Usage:
% genpass-wordlist [options]
=head1 DESCRIPTION
Using password from dictionary words (in this case, from WordList::*) can be
useful for humans when remembering the password. Note that using a string of
random characters is generally better because of the larger space (combination).
Using a password of two random words from a 5000-word wordlist has a space of
only ~25 million while an 8-character of random uppercase letters/lowercase
letters/numbers has a space of 62^8 = ~218 trillion. To increase the space
you'll need to use more words (e.g. 3 to 5 instead of just 2). This is important
if you are using the password for something that can be bruteforced quickly e.g.
for protecting on-disk ZIP/GnuPG file and the attacker has access to your file.
It is then recommended to use a high number of rounds for hashing to slow down
password cracking (e.g. C<--s2k-count 65011712> in GnuPG).
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
=item B<--num>=I<s>, B<-n>
Default value:
1
=item B<--pattern>=I<s@>, B<-p>
Pattern(s) to use.
Default value:
["%w %w %w","%w %w %w %w","%w %w %w %w %w","%w %w %w %w %w %w","%W%4d%W","%W%6d%s"]
A pattern is string that is similar to a printf pattern. %P (where P is certain
letter signifying a format) will be replaced with some other string. %NP (where
N is a number) will be replaced by a word of length N, %N$Mw (where N and M is a
number) will be replaced by a word of length between N and M. Anything else will
be used as-is. Available conversions:
%w Random word, all lowercase.
%W Random word, first letter uppercase, the rest lowercase.
%s Random ASCII symbol, e.g. "-" (dash), "_" (underscore), etc.
%d Random digit (0-9).
%% A literal percent sign.
Can be specified multiple times.
=item B<--patterns-json>=I<s>
Pattern(s) to use (JSON-encoded).
See C<--pattern>.
=item B<--wordlist>=I<s@>, B<-w>
Select one or more wordlist modules.
Can be specified multiple times.
=item B<--wordlists-json>=I<s>
Select one or more wordlist modules (JSON-encoded).
See C<--wordlist>.
=back
=head2 Configuration options
script/genpass-wordlist view on Meta::CPAN
#
# $opts //= {};
#
# $opts->{allow_unknown_properties} //= 0;
# $opts->{normalize_sah_schemas} //= 1;
# $opts->{remove_internal_properties} //= 0;
#
# require Sah::Schema::rinci::function_meta;
# my $sch = $Sah::Schema::rinci::function_meta::schema;
# my $sch_proplist = $sch->[1]{_prop}
# or die "BUG: Rinci schema structure changed (1a)";
#
# _normalize($meta, 1.1, $opts, $sch_proplist, {}, '');
#}
#
#1;
#
#__END__
#
### Sah/Schema/rinci/function_meta.pm ###
#package Sah::Schema::rinci::function_meta;
#
#our $DATE = '2016-12-26';
#our $VERSION = '1.1.82.2';
#
#use 5.010001;
#use strict;
#use warnings;
#
#use Data::Sah::Normalize ();
#use Sah::Schema::rinci::meta ();
#
#our $schema = [hash => {
# summary => 'Rinci function metadata',
#
# _ver => 1.1,
# _prop => {
# %Sah::Schema::rinci::meta::_dh_props,
#
# entity_v => {},
# entity_date => {},
# links => {},
#
# is_func => {},
# is_meth => {},
# is_class_meth => {},
# args => {
# _value_prop => {
# %Sah::Schema::rinci::meta::_dh_props,
#
# links => {},
#
# schema => {},
# filters => {},
# default => {},
# req => {},
# pos => {},
# greedy => {},
# partial => {},
# stream => {},
# is_password => {},
# cmdline_aliases => {
# _value_prop => {
# summary => {},
# description => {},
# schema => {},
# code => {},
# is_flag => {},
# },
# },
# cmdline_on_getopt => {},
# cmdline_prompt => {},
# completion => {},
# index_completion => {},
# element_completion => {},
# cmdline_src => {},
# meta => 'fix',
# element_meta => 'fix',
# deps => {
# _keys => {
# arg => {},
# all => {},
# any => {},
# none => {},
# },
# },
# },
# },
# args_as => {},
# args_rels => {},
# result => {
# _prop => {
# %Sah::Schema::rinci::meta::_dh_props,
#
# schema => {},
# statuses => {
# _value_prop => {
# summary => {},
# description => {},
# schema => {},
# },
# },
# partial => {},
# stream => {},
# },
# },
# result_naked => {},
# examples => {
# _elem_prop => {
# %Sah::Schema::rinci::meta::_dh_props,
#
# args => {},
# argv => {},
# src => {},
# src_plang => {},
# status => {},
# result => {},
# test => {},
# },
# },
# features => {
( run in 1.394 second using v1.01-cache-2.11-cpan-f56aa216473 )