diff options
author | axtloss <axtlos@getcryst.al> | 2024-07-12 18:03:44 +0200 |
---|---|---|
committer | axtloss <axtlos@getcryst.al> | 2024-07-12 18:03:44 +0200 |
commit | 4cc2091808a4bfe0e8ebf313919b71bd6ea92ffb (patch) | |
tree | 24a350ff6ead89dc39a18d72a864ebe1251e5b8e | |
parent | 10a544e989b0fa64c7f625433ae09b3d3576aed9 (diff) | |
download | shabottom-main.tar.gz shabottom-main.tar.bz2 |
-rwxr-xr-x | shabottom | bin | 31856 -> 0 bytes | |||
-rw-r--r-- | shabottom.c | 96 |
2 files changed, 96 insertions, 0 deletions
diff --git a/shabottom b/shabottom Binary files differdeleted file mode 100755 index 45bcd4e..0000000 --- a/shabottom +++ /dev/null diff --git a/shabottom.c b/shabottom.c new file mode 100644 index 0000000..10100c9 --- /dev/null +++ b/shabottom.c @@ -0,0 +1,96 @@ +/* crypto.c + * + * Copyright 2024 axtlos <axtlos@disroot.org> + * + * 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 + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include <stdint.h> +#include <time.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +const char start[10] = {'s','s','s','d','d','d','f','f','f','f'}; +const char end[11] = {'g','g','g','h','h','h','j','k','l','l','l'}; + +unsigned int +get_data(char *file) +{ + unsigned int ret = 0; + FILE *data = NULL; + if (file) { + data = fopen (file, "r"); + } else { + data = stdin; + } + unsigned int character; + while ((character = fgetc (data)) != EOF) { + ret = ret + character; + } + return ret; +} + +int +main (int argc, char *argv[]) { + + char *keymash = malloc(33); + int r,total = 0; + char prev = 'a'; + int val = 0; + int switchup = 0; + + int from_stdin = argc > 1 ? 1 : 0; + unsigned int data = 0; + data = get_data (from_stdin == 0 ? NULL : argv[argc-1]); + srand(data); + total += sprintf(keymash+total, "%c", prev); + while (total < 32) { + if (val == 0) { + int j = total+2 < 32 ? 2 : 1; + for (int i = 0; i < j; i++) { + r = abs((rand() % 10 - r) + r); + if (prev != start[r]) { + total += sprintf(keymash+total, "%c", start[r]); + prev = start[r]; + } else { + i -= 1; + } + } + switchup = switchup < 0 ? 0 : switchup+1; + } else if (val == 1) { + int j = total+2 < 32 ? 2 : 1; + for (int i = 0; i < j; i++) { + r = abs((rand() % 11)); + if (prev != end[r]) { + total += sprintf(keymash+total, "%c", end[r]); + prev = end[r]; + } else { + i -= 1; + } + } + switchup = switchup > 0 ? 0 : switchup-1; + } + if (switchup < 2 && switchup > -2) { + val = abs(rand() % 2); + } else { + val = switchup < 0 ? 0 : 1; + } + } + puts(keymash); + free(keymash); + return 0; + +} |