Add -n flag for outputting numbers only (for PINs, etc.)

This commit is contained in:
Chris Oei 2012-09-08 09:53:27 -07:00
parent f9f61afa4c
commit d93ca58d76
6 changed files with 39 additions and 15 deletions

10
main.c
View file

@ -41,7 +41,7 @@ usage(void)
{
fprintf(stderr,
"usage: scrypt-genpass [-l LEN] [-m MAXMEM] [-o MAXOPS] [-k KEYFILE] [-p PASS] <site>\n");
"usage: scrypt-genpass [-l LEN] [-m MAXMEM] [-n] [-o MAXOPS] [-k KEYFILE] [-p PASS] <site>\n");
fprintf(stderr,
" scrypt-genpass -t\n");
exit(1);
@ -81,6 +81,7 @@ main(int argc, char *argv[])
char ch;
char * keyfile = NULL;
uint8_t* passwd = NULL;
int numbers_only = 0;
int rc;
#ifdef NEED_WARN_PROGNAME
@ -91,7 +92,7 @@ main(int argc, char *argv[])
usage();
/* Parse arguments. */
while ((ch = getopt(argc, argv, "htk:l:m:o:p:")) != -1) {
while ((ch = getopt(argc, argv, "htk:l:m:no:p:")) != -1) {
switch (ch) {
case 'k':
keyfile = strdup(optarg);
@ -101,6 +102,9 @@ main(int argc, char *argv[])
case 'm':
maxmem = atoi(optarg);
break;
case 'n':
numbers_only++;
break;
case 'o':
megaops = atoi(optarg);
break;
@ -188,7 +192,7 @@ main(int argc, char *argv[])
}
char output[outputlength + 1];
hashtopass(output, outputlength, dk);
hashtopass(numbers_only, output, outputlength, dk);
printf("Generated password: %s\n", output);
memset(output, 0, outputlength + 1);