import java.io.File; import java.io.FileFilter; import java.io.FileNotFoundException; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.util.Random; import java.util.Vector; import java.util.Hashtable; import java.util.Arrays; public class Variation { // Password variables private int[] status; // Current process status for restart support final int DUMP_MAX = 10000; // Max. amount of passwords in memory before clearing & dumping private String[] generated; // Passwords tried. private String vary; private char[] varyArray; StringBuilder builder; private Hashtable lookup = new Hashtable(); /** * @param args */ public static void main(String[] args) { Variation c = new Variation("emmatruitjemaria"); c.makeVariations(); System.exit(0); } public Variation(String pwd) { this.vary = pwd; this.varyArray = vary.toCharArray(); builder = new StringBuilder(vary.length()); this.status = new int[pwd.length()]; this.Prepare(); } private void Prepare() { this.lookup.put('e', new String[]{"e","E","3","#"}); this.lookup.put('a',new String[]{"a","A","4","$",""}); // Empty for 'a'-'Caps lock' mix up. this.lookup.put('m',new String[]{"m","M",""}); // Faulty keyboard this.lookup.put('t',new String[]{"t","T"}); this.lookup.put('r',new String[]{"r","R"}); this.lookup.put('u',new String[]{"u","U"}); this.lookup.put('i',new String[]{"i","I","1","!"}); this.lookup.put('j',new String[]{"j","J"}); this.generated = new String[DUMP_MAX]; } public void makeVariations() { long start = System.currentTimeMillis(); String passWord= ""; int tmpCnt = 0; int current = 0; int batch = 0; while(!passWord.equals(this.vary)) { passWord = ApplyVariation(); generated[current++] = passWord; tmpCnt++; if(current>=DUMP_MAX) { // Dump generated passwords dumpGenerated(generated, batch++); current=0; generated = new String[DUMP_MAX]; } } long tookMe = System.currentTimeMillis() - start; System.out.format("Done! Made %d passwords\n", tmpCnt); System.out.println("It took me "+ (tookMe/1000.00) + " sec. or " + (tookMe/1000.00)/60.00 +" min. "); } private String ApplyVariation() { int carry = 1; int tmp; int size; for(int i=vary.length()-1; i>=0 && carry==1; i--) { size = lookup.get(varyArray[i]).length; tmp = status[i] + 1; status[i] = (tmp % size); carry = (tmp / size); } builder = new StringBuilder(vary.length()); for(int i=0;i