Simple Dictionary Generator

This is a very simple dictionary generator written in C. The code is as minimalistic as possible and performs no error checking whatsoever. The arguments supplied at the command line are assumed to be "perfect", otherwise the program will crash.

The program takes two command line arguments:
gen [password length] [alphabet]
The "password length" is the amount of characters each password will contain. The maximum is 64 (but you can change this in the code).

The "alphabet" is the list of characters you wish to use.

Here's some sample usages:
gen 6 abcdefghijklmnopqrstuvwxyz 

gen 4 0123456789abcdef
The output of this program is printed to "stdout". If you wish to create a dictionary file, you can pipe the output to a file as follows:
gen 4 0123456789abcdef > my_dictionary.txt
Here's the source code for it:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

void Combinate(char const *const pstart,char *const p,
               char const *const plast,char const *const alphabet)
    for (*p = alphabet[0]; *p; *p = strchr(alphabet,*p)[1])
        if (p == plast)

int main(int argc, char **argv)
    char str[64 + 1] = {0};

    Combinate(str,str,str + strtoul(argv[1],0,10) - 1,argv[2]);

    return 0;
You can copy this code into a file named "gen.c" and then compile it as follows:
gcc gen.c -D NDEBUG -s -O3 -o gen

Virjacode Home