summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2019-03-09 20:35:36 -0700
committerAaron Ball <nullspoon@oper.io>2019-03-09 20:35:36 -0700
commit6944610fe3752c64bda5e03c57311f87baa64ac6 (patch)
tree77580f236e2d492cd277b13b73ec6dbed00960a8
parent67e1f43a0fd98d27c6d32c7def9a15ccc223aad4 (diff)
downloadupwgen-6944610fe3752c64bda5e03c57311f87baa64ac6.tar.gz
upwgen-6944610fe3752c64bda5e03c57311f87baa64ac6.tar.xz
Add debug support
Added support for the -d,--debug switches. These will cause upwgen to dump the assembled character array to stdout with hexidecimal and decimal codes. Also prints a total pool character count.
-rw-r--r--src/i18n_cat.c4
-rw-r--r--src/main.c9
2 files changed, 12 insertions, 1 deletions
diff --git a/src/i18n_cat.c b/src/i18n_cat.c
index 18712ac..f8d9f05 100644
--- a/src/i18n_cat.c
+++ b/src/i18n_cat.c
@@ -275,8 +275,10 @@ unsigned int i18n_cat_four(unsigned int* dest) {
void i18n_dump_arr(unsigned int* arr) {
int i = 0; // cursor
+ printf("Hex Decimal [Character]\n");
while(arr[i] != '\0') {
- printf("0x%04x %5d: [%lc]\n", arr[i], arr[i], arr[i]);
+ printf("0x%04x %-7d [%lc]\n", arr[i], arr[i], arr[i]);
i++;
}
+ printf("\nCount: %d\n\n", i);
}
diff --git a/src/main.c b/src/main.c
index cb22210..1111a2c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,7 @@ void usage() {
" -4 Include chars from the forth most used scripts in the world\n"
"\n"
" -h,--help Print this help text\n"
+ " -d,--debug Enable debug mode (prints entire character pool)\n"
);
}
@@ -48,12 +49,14 @@ void usage() {
int main(int argc, char* argv[]) {
struct timespec ts; // Timespec for seeding rng
unsigned int count; // Number of chars to choose from
+ int debug; // Debug mode switch
int len; // Password length
int i; // Arg index
unsigned long seed; // Seed for the RNG (current seconds * nanoseconds)
unsigned int chars[4096]; // Uint array to hold international chars
// Initialize
+ debug = 0;
count = 0;
len = 32;
i = 1;
@@ -95,6 +98,9 @@ int main(int argc, char* argv[]) {
usage();
return 0;
+ } else if(strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--debug") == 0) {
+ debug = 1;
+
} else {
// If we reach this block, the user specified a custom length (or
// fatfingered something). Test for ability to convert from str to int
@@ -114,6 +120,9 @@ int main(int argc, char* argv[]) {
if(chars[0] == '\0')
count += i18n_cat_ascii(chars);
+ if(debug)
+ i18n_dump_arr(chars);
+
// Get the random data seed
clock_gettime(CLOCK_REALTIME, &ts);
seed = ts.tv_sec + ts.tv_nsec;

Generated by cgit