diff options
| author | @syxhe <https://t.me/syxhe> | 2024-08-30 19:29:53 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2024-08-30 19:29:53 -0500 |
| commit | e51f37f52c4452be1c2cacf5969e6d754eaecc70 (patch) | |
| tree | 6fc8c2124b9ab2f4a8c8e9bdd598c9d3021c00e7 /src/VX-GAMBLEGROUND.c | |
| parent | 80ed3fd818905cb08ad04abc166a4b2c936955e3 (diff) | |
Put passphrase on main window
Diffstat (limited to 'src/VX-GAMBLEGROUND.c')
| -rw-r--r-- | src/VX-GAMBLEGROUND.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/VX-GAMBLEGROUND.c b/src/VX-GAMBLEGROUND.c index e905de4..c01ee5c 100644 --- a/src/VX-GAMBLEGROUND.c +++ b/src/VX-GAMBLEGROUND.c | |||
| @@ -35,8 +35,6 @@ | |||
| 35 | #include <stdio.h> | 35 | #include <stdio.h> |
| 36 | #include <threads.h> | 36 | #include <threads.h> |
| 37 | 37 | ||
| 38 | #define PHRASESIZE 32 | ||
| 39 | |||
| 40 | const char *argp_program_version = "Alpha-0.1"; | 38 | const char *argp_program_version = "Alpha-0.1"; |
| 41 | const char *argp_program_bug_address = "@syxhe on Telegram (https://t.me/syxhe)"; | 39 | const char *argp_program_bug_address = "@syxhe on Telegram (https://t.me/syxhe)"; |
| 42 | 40 | ||
| @@ -87,11 +85,11 @@ static struct argp argp = {options, parse_opt, argdoc, doc, NULL, 0, 0}; | |||
| 87 | 85 | ||
| 88 | int genphrase(char *phrase, size_t phrasesize) { | 86 | int genphrase(char *phrase, size_t phrasesize) { |
| 89 | memset(phrase, 0, phrasesize); | 87 | memset(phrase, 0, phrasesize); |
| 90 | for(size_t i = 0; i < phrasesize; i++) { | 88 | for(size_t i = 0; i < phrasesize; i++) |
| 91 | phrase[i] = randombytes_uniform(('Z' - 'A') + 1) + 'A'; | 89 | phrase[i] = randombytes_uniform('Z' - 'A' + 1) + 'A'; |
| 92 | if(randombytes_random() > (0xffffffff / 2)) | 90 | phrase[phrasesize] = '\0'; |
| 93 | phrase[i] += ('a' - 'A'); | 91 | |
| 94 | } | 92 | printf("%s\n", phrase); |
| 95 | 93 | ||
| 96 | return 0; | 94 | return 0; |
| 97 | } | 95 | } |
| @@ -109,7 +107,7 @@ int doslots(struct bullshit *stuff) { | |||
| 109 | 107 | ||
| 110 | getmaxyx(stdscr, stuff->row, stuff->col); | 108 | getmaxyx(stdscr, stuff->row, stuff->col); |
| 111 | stuff->randphrase = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); | 109 | stuff->randphrase = randombytes_uniform(STATIC_ARRSIZE(phrases) + 1); |
| 112 | stuff->banner = create_banner(stuff->col, stuff->randphrase); | 110 | stuff->banner = create_banner(stuff->col, stuff->randphrase, stuff->passphrase); |
| 113 | 111 | ||
| 114 | init_items(stuff->items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); | 112 | init_items(stuff->items, menu_choices, STATIC_ARRSIZE(menu_choices), userfuncs); |
| 115 | stuff->menu = new_menu(stuff->items); | 113 | stuff->menu = new_menu(stuff->items); |
| @@ -154,7 +152,7 @@ int doslots(struct bullshit *stuff) { | |||
| 154 | 152 | ||
| 155 | int doslots_twrapper(void *passed) { | 153 | int doslots_twrapper(void *passed) { |
| 156 | return doslots((struct bullshit*)passed); | 154 | return doslots((struct bullshit*)passed); |
| 157 | }; | 155 | } |
| 158 | 156 | ||
| 159 | 157 | ||
| 160 | int main(int argc, char *argv[]) { | 158 | int main(int argc, char *argv[]) { |
| @@ -167,12 +165,22 @@ int main(int argc, char *argv[]) { | |||
| 167 | if(args.flags == (SKIPENC | SKIPSLOTS)) | 165 | if(args.flags == (SKIPENC | SKIPSLOTS)) |
| 168 | error(1, 0, "[VX-GAMBLEGROUND] You want to skip the slots, and the encryption? Ok, sure"); | 166 | error(1, 0, "[VX-GAMBLEGROUND] You want to skip the slots, and the encryption? Ok, sure"); |
| 169 | 167 | ||
| 168 | |||
| 169 | // C is truly a mystery sometimes. If this is statically defined, shit breaks. But when I allocate it? Just works | ||
| 170 | char *passphrase = calloc(PHRASESIZE + 1, sizeof(*passphrase)); | ||
| 171 | if(args.inputpass == NULL) { | ||
| 172 | genphrase(passphrase, PHRASESIZE); | ||
| 173 | } else { | ||
| 174 | passphrase = args.inputpass; | ||
| 175 | } | ||
| 176 | |||
| 177 | |||
| 170 | struct bullshit stuff; | 178 | struct bullshit stuff; |
| 179 | strncpy(stuff.passphrase, passphrase, PHRASESIZE); | ||
| 171 | thrd_t slots; | 180 | thrd_t slots; |
| 172 | int err; | 181 | int err; |
| 173 | |||
| 174 | if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success) | 182 | if((err = thrd_create(&slots, doslots_twrapper, (void*)&stuff)) != thrd_success) |
| 175 | error(1, 0, "Thread creation failed"); | 183 | error(1, 0, "Thread creation failed: %d", err); |
| 176 | 184 | ||
| 177 | 185 | ||
| 178 | // if(args.inputpass != NULL) { | 186 | // if(args.inputpass != NULL) { |
