// SPDX-License-Identifier: BSD-3-Clause #include #include #include #include #include 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'}; int main (int argc, char *argv[]) { if (argc <= 1) { puts("Give me the keymash length!"); return 1; } int keymashlength = atoi(argv[1]); if (keymashlength <= 0) { puts("Bad length >:("); return 1; } char *keymash = malloc(keymashlength+1); int r,total = 0; char prev = 'a'; int val = 0; int switchup = 0; srand(time(NULL)); total += sprintf(keymash+total, "%c", prev); while (total < keymashlength) { if (val == 0) { int j = total+2 < keymashlength ? 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]; //total += 1; } else { i -= 1; } } switchup = switchup < 0 ? 0 : switchup+1; } else if (val == 1) { int j = total+2 < keymashlength ? 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; }