mirror of
https://codeberg.org/scip/diceware.git
synced 2025-12-16 18:30:58 +01:00
added option -y to support passwords for policy-enabled sites
This commit is contained in:
55
dicepwgen.c
55
dicepwgen.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of dicepwgen
|
* This file is part of dicepwgen
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 T.v.Dein.
|
* Copyright (C) 2015-2016 T.v.Dein.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -23,21 +23,22 @@
|
|||||||
|
|
||||||
int usage() {
|
int usage() {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Generate a random diceware passphrase\n"
|
"Generate a random diceware passphrase\n"
|
||||||
"Usage: dice [-tcfvhd]\n"
|
"Usage: dice [-tcfvhd]\n"
|
||||||
"Options: \n"
|
"Options: \n"
|
||||||
"-t --humantoss Asks interactively for rolled dices\n"
|
"-t --humantoss Asks interactively for rolled dices\n"
|
||||||
"-c --wordcount <count> Number of words (default: 4)\n"
|
"-c --wordcount <count> Number of words (default: 4)\n"
|
||||||
"-f --dictfile <dictfile> Dictionary file to use (default:\n"
|
"-f --dictfile <dictfile> Dictionary file to use (default:\n"
|
||||||
" /usr/share/dict/american-english)\n"
|
" /usr/share/dict/american-english)\n"
|
||||||
"-l --minlen <count> Minimum word len (default: 5)\n"
|
"-l --minlen <count> Minimum word len (default: 5)\n"
|
||||||
"-m --maxlen <count> Maximum word len (default: 10)\n"
|
"-m --maxlen <count> Maximum word len (default: 10)\n"
|
||||||
"-n --dontjump Use all words in the dict file, e.g.\n"
|
"-n --dontjump Use all words in the dict file, e.g.\n"
|
||||||
" if it is an original diceware list\n"
|
" if it is an original diceware list\n"
|
||||||
"-d --debug Enable debug output\n"
|
"-y --symbols Replace space with -, add non-letters\n"
|
||||||
"-v --version Print program version\n"
|
"-d --debug Enable debug output\n"
|
||||||
"-h -? --help Print this help screen\n"
|
"-v --version Print program version\n"
|
||||||
);
|
"-h -? --help Print this help screen\n"
|
||||||
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ int main (int argc, char **argv) {
|
|||||||
|
|
||||||
WMIN = 6;
|
WMIN = 6;
|
||||||
WMAX = 10;
|
WMAX = 10;
|
||||||
humantoss = verbose = dontjump = 0;
|
humantoss = verbose = dontjump = symbols = 0;
|
||||||
|
|
||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
{ "wordcount", required_argument, NULL, 'c' },
|
{ "wordcount", required_argument, NULL, 'c' },
|
||||||
@@ -56,13 +57,14 @@ int main (int argc, char **argv) {
|
|||||||
{ "maxlen", required_argument, NULL, 'm' },
|
{ "maxlen", required_argument, NULL, 'm' },
|
||||||
{ "humantoss", required_argument, NULL, 't' },
|
{ "humantoss", required_argument, NULL, 't' },
|
||||||
{ "dictfile", required_argument, NULL, 'f' },
|
{ "dictfile", required_argument, NULL, 'f' },
|
||||||
{ "dontjump", no_argument, NULL, 'n' },
|
{ "dontjump", no_argument, NULL, 'n' },
|
||||||
|
{ "symbols", no_argument, NULL, 'y' },
|
||||||
{ "version", no_argument, NULL, 'v' },
|
{ "version", no_argument, NULL, 'v' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ "debug", no_argument, NULL, 'd' },
|
{ "debug", no_argument, NULL, 'd' },
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "l:m:tf:c:vh?dn", longopts, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, "l:m:tf:c:vh?dny", longopts, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'v':
|
case 'v':
|
||||||
fprintf(stderr, "This is %s version %s\n", argv[0], VERSION);
|
fprintf(stderr, "This is %s version %s\n", argv[0], VERSION);
|
||||||
@@ -84,6 +86,9 @@ int main (int argc, char **argv) {
|
|||||||
case 't':
|
case 't':
|
||||||
humantoss = 1;
|
humantoss = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'y':
|
||||||
|
symbols = 1;
|
||||||
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
@@ -130,6 +135,7 @@ void getwords(char *dictfile, int count) {
|
|||||||
char **words;
|
char **words;
|
||||||
int i, pos, one, two, three, four, five;
|
int i, pos, one, two, three, four, five;
|
||||||
int *tossed;
|
int *tossed;
|
||||||
|
char sep = ' ';
|
||||||
unsigned char *tosses;
|
unsigned char *tosses;
|
||||||
|
|
||||||
words = fetch_dict(dictfile);
|
words = fetch_dict(dictfile);
|
||||||
@@ -152,10 +158,17 @@ void getwords(char *dictfile, int count) {
|
|||||||
free(tosses);
|
free(tosses);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i<count; i++) {
|
if(symbols)
|
||||||
fprintf(stdout, "%s ", words[tossed[i]]);
|
sep = '-';
|
||||||
|
|
||||||
|
for(i=0; i<count-1; i++) {
|
||||||
|
fprintf(stdout, "%s%c", words[tossed[i]], sep);
|
||||||
}
|
}
|
||||||
|
fprintf(stdout, "%s", words[tossed[count-1]]);
|
||||||
|
|
||||||
|
if(symbols)
|
||||||
|
fprintf(stdout, "%%8");
|
||||||
|
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
free(tossed);
|
free(tossed);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of dicepwgen
|
* This file is part of dicepwgen
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 T.v.Dein.
|
* Copyright (C) 2015-2016 T.v.Dein.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -37,12 +37,13 @@
|
|||||||
#define STRINGIZE(x) #x
|
#define STRINGIZE(x) #x
|
||||||
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
|
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
|
||||||
|
|
||||||
#define VERSION "1.0"
|
#define VERSION "1.1"
|
||||||
#define RLEN 1024
|
#define RLEN 1024
|
||||||
|
|
||||||
int humantoss;
|
int humantoss;
|
||||||
int verbose;
|
int verbose;
|
||||||
int dontjump;
|
int dontjump;
|
||||||
|
int symbols;
|
||||||
int WMIN;
|
int WMIN;
|
||||||
int WMAX;
|
int WMAX;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ dicepwgen - A diceware password generator
|
|||||||
-m --maxlen <count> Maximum word len (default: 10)
|
-m --maxlen <count> Maximum word len (default: 10)
|
||||||
-n --dontjump Use all words in the dict file, e.g.
|
-n --dontjump Use all words in the dict file, e.g.
|
||||||
if it is an original diceware list
|
if it is an original diceware list
|
||||||
|
-y --symbols Replace space with -, add non-letters
|
||||||
-d --debug Enable debug output
|
-d --debug Enable debug output
|
||||||
-v --version Print program version
|
-v --version Print program version
|
||||||
-h -? --help Print this help screen
|
-h -? --help Print this help screen
|
||||||
@@ -37,7 +38,11 @@ If you're using a precomputed diceware list, use the parameter
|
|||||||
B<-n>, in which case dicepwgen will use all entries in the file.
|
B<-n>, in which case dicepwgen will use all entries in the file.
|
||||||
|
|
||||||
The program only uses words which contain 7bit ASCII letters
|
The program only uses words which contain 7bit ASCII letters
|
||||||
(a-zA-Z0-9), which are easier for password usage anyway.
|
(a-zA-Z0-9), which are easier for password usage anyway. However,
|
||||||
|
some sites have so called "password policies" applied and do
|
||||||
|
not support whitespaces and/or require special symbols to be
|
||||||
|
part of the password. Use -y in such cases which uses - as
|
||||||
|
word separator and adds %8 to the end of the password.
|
||||||
|
|
||||||
=head1 FILES
|
=head1 FILES
|
||||||
|
|
||||||
@@ -91,7 +96,7 @@ again and again til the required number of words has been collected (7776).
|
|||||||
|
|
||||||
This software is licensed under the GNU GENERAL PUBLIC LICENSE version 3.
|
This software is licensed under the GNU GENERAL PUBLIC LICENSE version 3.
|
||||||
|
|
||||||
Copyright (c) 2015 by T. v. Dein.
|
Copyright (c) 2015-2016 by T. v. Dein.
|
||||||
|
|
||||||
=head1 AUTHORS
|
=head1 AUTHORS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user