mirror of
https://codeberg.org/scip/diceware.git
synced 2025-12-16 10:20:57 +01:00
allow 0-9 in words as well
This commit is contained in:
@@ -56,6 +56,8 @@ modify `$PREFIX` during installation time like this:
|
||||
/usr/share/dict/american-english)
|
||||
-l --minlen <count> Minimum word len (default: 5)
|
||||
-m --maxlen <count> Maximum word len (default: 10)
|
||||
-n --dontjump Use all words in the dict file, e.g.
|
||||
if it is an original diceware list
|
||||
-d --debug Enable debug output
|
||||
-v --version Print program version
|
||||
-h -? --help Print this help screen
|
||||
|
||||
41
dicepwgen.1
41
dicepwgen.1
@@ -133,7 +133,7 @@
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "DICEPWGEN 1"
|
||||
.TH DICEPWGEN 1 "2015-08-02" "perl v5.18.2" "User Contributed Perl Documentation"
|
||||
.TH DICEPWGEN 1 "2015-08-03" "perl v5.18.2" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
@@ -142,7 +142,7 @@
|
||||
dicepwgen \- A diceware password generator
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
.Vb 11
|
||||
.Vb 10
|
||||
\& Usage: dice [\-tcfvhd]
|
||||
\& Options:
|
||||
\& \-t \-\-humantoss Asks interactively for rolled dices
|
||||
@@ -151,6 +151,8 @@ dicepwgen \- A diceware password generator
|
||||
\& /usr/share/dict/american\-english)
|
||||
\& \-l \-\-minlen <count> Minimum word len (default: 5)
|
||||
\& \-m \-\-maxlen <count> Maximum word len (default: 10)
|
||||
\& \-n \-\-dontjump Use all words in the dict file, e.g.
|
||||
\& if it is an original diceware list
|
||||
\& \-d \-\-debug Enable debug output
|
||||
\& \-v \-\-version Print program version
|
||||
\& \-h \-? \-\-help Print this help screen
|
||||
@@ -170,11 +172,35 @@ minimum and maximum word length.
|
||||
You can tell dicepwgen to use another dictionary file with
|
||||
the option \fB\-f\fR.
|
||||
.PP
|
||||
If you're using a precomputed diceware list, use the parameter
|
||||
\&\fB\-n\fR, in which case dicepwgen will use all entries in the file.
|
||||
.PP
|
||||
The program only uses words which contain 7bit \s-1ASCII\s0 letters
|
||||
(a\-zA-Z), which are easier for password usage anyway.
|
||||
(a\-zA\-Z0\-9), which are easier for password usage anyway.
|
||||
.SH "FILES"
|
||||
.IX Header "FILES"
|
||||
\&\fB/usr/share/dict/american\-english\fR: default dictionary file.
|
||||
.PP
|
||||
You can use almost any dictionary file you want. Dicepwgen expects
|
||||
the file to be in the following format: one word per line.
|
||||
.PP
|
||||
You can also use precomputed diceware word lists by adding the
|
||||
option \fB\-n\fR to the commandline. If the file already contains
|
||||
numbers, you have to remove them before using. Say, the file
|
||||
looks like this:
|
||||
.PP
|
||||
.Vb 4
|
||||
\& 11126 abase
|
||||
\& 11131 abash
|
||||
\& 11132 abate
|
||||
\& 11133 abbas
|
||||
.Ve
|
||||
.PP
|
||||
Prepare the file with this shell oneliner:
|
||||
.PP
|
||||
.Vb 1
|
||||
\& grep "^[0\-9]" dicewarelist.txt | awk \*(Aq{print $2}\*(Aq >> newlist.txt
|
||||
.Ve
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
<http://world.std.com/~reinhold/diceware.html>
|
||||
@@ -185,6 +211,15 @@ The program only uses words which contain 7bit \s-1ASCII\s0 letters
|
||||
In order to report a bug, unexpected behavior, feature requests
|
||||
or to submit a patch, please open an issue on github:
|
||||
<https://github.com/TLINDEN/diceware/issues>.
|
||||
.PP
|
||||
Current known issues:
|
||||
.IP "\(bu" 4
|
||||
The program does not count the lines in a dictionary file before
|
||||
using it. If the file contains a low number of entries (e.g. because
|
||||
it is a precomputed diceware word list and \fB\-n\fR has not been
|
||||
specified), it seems to \*(L"hang\*(R". In fact it runs very long because it
|
||||
jumps over a random number of entries and restarts from the beginning
|
||||
again and again til the required number of words has been collected (7776).
|
||||
.SH "LICENSE"
|
||||
.IX Header "LICENSE"
|
||||
This software is licensed under the \s-1GNU GENERAL PUBLIC LICENSE\s0 version 3.
|
||||
|
||||
16
dicepwgen.c
16
dicepwgen.c
@@ -32,6 +32,8 @@ int usage() {
|
||||
" /usr/share/dict/american-english)\n"
|
||||
"-l --minlen <count> Minimum word len (default: 5)\n"
|
||||
"-m --maxlen <count> Maximum word len (default: 10)\n"
|
||||
"-n --dontjump Use all words in the dict file, e.g.\n"
|
||||
" if it is an original diceware list\n"
|
||||
"-d --debug Enable debug output\n"
|
||||
"-v --version Print program version\n"
|
||||
"-h -? --help Print this help screen\n"
|
||||
@@ -46,8 +48,7 @@ int main (int argc, char **argv) {
|
||||
|
||||
WMIN = 6;
|
||||
WMAX = 10;
|
||||
humantoss = 0;
|
||||
verbose = 0;
|
||||
humantoss = verbose = dontjump = 0;
|
||||
|
||||
static struct option longopts[] = {
|
||||
{ "wordcount", required_argument, NULL, 'c' },
|
||||
@@ -55,12 +56,13 @@ int main (int argc, char **argv) {
|
||||
{ "maxlen", required_argument, NULL, 'm' },
|
||||
{ "humantoss", required_argument, NULL, 't' },
|
||||
{ "dictfile", required_argument, NULL, 'f' },
|
||||
{ "dontjump", no_argument, NULL, 'n' },
|
||||
{ "version", no_argument, NULL, 'v' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "debug", no_argument, NULL, 'd' },
|
||||
};
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "l:m:tf:c:vh?d", longopts, NULL)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "l:m:tf:c:vh?dn", longopts, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'v':
|
||||
fprintf(stderr, "This is %s version %s\n", argv[0], VERSION);
|
||||
@@ -85,6 +87,9 @@ int main (int argc, char **argv) {
|
||||
case 'd':
|
||||
verbose++;
|
||||
break;
|
||||
case 'n':
|
||||
dontjump = 1;
|
||||
break;
|
||||
case 'f':
|
||||
dictfile = malloc(strlen(optarg));
|
||||
strncpy(dictfile, optarg, strlen(optarg));
|
||||
@@ -99,6 +104,11 @@ int main (int argc, char **argv) {
|
||||
dictfile = STRINGIZE_VALUE_OF(DICTFILE);
|
||||
}
|
||||
|
||||
if(dontjump) {
|
||||
WMIN = 0;
|
||||
WMAX = 128;
|
||||
}
|
||||
|
||||
debug(" using dictfile: %s", dictfile);
|
||||
debug("minimum word length: %d", WMIN);
|
||||
debug("maximum word length: %d", WMAX);
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
int humantoss;
|
||||
int verbose;
|
||||
int dontjump;
|
||||
int WMIN;
|
||||
int WMAX;
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ dicepwgen - A diceware password generator
|
||||
/usr/share/dict/american-english)
|
||||
-l --minlen <count> Minimum word len (default: 5)
|
||||
-m --maxlen <count> Maximum word len (default: 10)
|
||||
-n --dontjump Use all words in the dict file, e.g.
|
||||
if it is an original diceware list
|
||||
-d --debug Enable debug output
|
||||
-v --version Print program version
|
||||
-h -? --help Print this help screen
|
||||
@@ -31,13 +33,33 @@ minimum and maximum word length.
|
||||
You can tell dicepwgen to use another dictionary file with
|
||||
the option B<-f>.
|
||||
|
||||
If you're using a precomputed diceware list, use the parameter
|
||||
B<-n>, in which case dicepwgen will use all entries in the file.
|
||||
|
||||
The program only uses words which contain 7bit ASCII letters
|
||||
(a-zA-Z), which are easier for password usage anyway.
|
||||
(a-zA-Z0-9), which are easier for password usage anyway.
|
||||
|
||||
=head1 FILES
|
||||
|
||||
B</usr/share/dict/american-english>: default dictionary file.
|
||||
|
||||
You can use almost any dictionary file you want. Dicepwgen expects
|
||||
the file to be in the following format: one word per line.
|
||||
|
||||
You can also use precomputed diceware word lists by adding the
|
||||
option B<-n> to the commandline. If the file already contains
|
||||
numbers, you have to remove them before using. Say, the file
|
||||
looks like this:
|
||||
|
||||
11126 abase
|
||||
11131 abash
|
||||
11132 abate
|
||||
11133 abbas
|
||||
|
||||
Prepare the file with this shell oneliner:
|
||||
|
||||
grep "^[0-9]" dicewarelist.txt | awk '{print $2}' >> newlist.txt
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<http://world.std.com/~reinhold/diceware.html>
|
||||
@@ -50,6 +72,21 @@ In order to report a bug, unexpected behavior, feature requests
|
||||
or to submit a patch, please open an issue on github:
|
||||
L<https://github.com/TLINDEN/diceware/issues>.
|
||||
|
||||
Current known issues:
|
||||
|
||||
=over
|
||||
|
||||
=item *
|
||||
|
||||
The program does not count the lines in a dictionary file before
|
||||
using it. If the file contains a low number of entries (e.g. because
|
||||
it is a precomputed diceware word list and B<-n> has not been
|
||||
specified), it seems to "hang". In fact it runs very long because it
|
||||
jumps over a random number of entries and restarts from the beginning
|
||||
again and again til the required number of words has been collected (7776).
|
||||
|
||||
=back
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
This software is licensed under the GNU GENERAL PUBLIC LICENSE version 3.
|
||||
|
||||
16
dictfile.c
16
dictfile.c
@@ -106,18 +106,20 @@ char **fetch_dict(char *dictfile) {
|
||||
|
||||
LOOP:
|
||||
while ((linelen = getline(&line, &len, DICT)) != -1) {
|
||||
if(jump > 0) {
|
||||
jump--;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
jump = rand_lim(32);
|
||||
if(! dontjump) {
|
||||
if(jump > 0) {
|
||||
jump--;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
jump = rand_lim(32);
|
||||
}
|
||||
}
|
||||
if(linelen >= WMIN+1 && linelen <= WMAX+1) {
|
||||
line[linelen-1] = '\0'; /* remove newline */
|
||||
|
||||
for(i=0; i<linelen-1; i++) {
|
||||
if(isalpha((int)line[i]) == 0) {
|
||||
if(isalnum((int)line[i]) == 0) {
|
||||
next = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
extern int WMIN;
|
||||
extern int WMAX;
|
||||
extern int dontjump;
|
||||
|
||||
int *incr_dicedigit(int *digits);
|
||||
int get_dicenum(int *digits);
|
||||
|
||||
Reference in New Issue
Block a user