I had to make bruteforce algorithm for my computer security class, so here it is. It uses MD5CryptoServiceProvider to create MD5 hash but the algorithm can be used by itself without creating a hash.
The idea is simple. All you have to do is provide collection of characters (char) you want to generate your words with and algorithm uses them as it would be creating a number – it takes chars one by one giving them indexes and adds them to the previous word like that:
Let’s say you have a number 379, algorithm will take the number 9, check it and find out that it’s the last digit possible so it will change the number 9 to the first digit – 0 and remember that it should „add +1” to the next sign so it will change 7 to 8 and remember „+0”. It will leave the sign ‚3’ without any changes and return 380 as string. The same rule goes with any char (sign) you will provide.
The algorithm is a lot better than the more obvious recusrsive implementation and it doesn’t give you the StackOverflowException on longer passwords 🙂 Also you can modify this method to start and end on the specified „word” so you can divide the whole work on more CPUs or machines.
Download link comes with console demo application.