public class hashabuse { static char letters[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; String base; int baseh; char basec[]; char curc[]; boolean sub[]; int ind[]; public static void main( String argv[] ) { String baseIn = "i like big butts"; int maxsub = 2; for ( int a = 0; a < argv.length; a++ ) { if ( argv[a].equals( "-d" ) ) { a++; maxsub = Integer.parseInt( argv[a] ); } else if ( argv[a].equals( "-all" ) ) { maxsub = baseIn.length(); } else { baseIn = argv[a]; } } System.err.println(".hashCode() equals \"" + baseIn + "\".hashCode()"); hashabuse it = new hashabuse( baseIn ); it.sub( maxsub, 0 ); } hashabuse( String bi ) { base = bi; baseh = base.hashCode(); basec = bi.toCharArray(); curc = bi.toCharArray(); sub = new boolean[basec.length]; ind = new int[basec.length]; } void sub( int depthlim, int pos ) { for ( ; pos < curc.length; pos++ ) { for ( int s = 0; s < letters.length; s++ ) { if ( basec[pos] == letters[s] ) { continue; } curc[pos] = letters[s]; String cur = new String( curc ); if ( cur.hashCode() == baseh ) { System.out.println( cur ); } if ( depthlim > 1 ) { sub( depthlim - 1, pos + 1 ); } } curc[pos] = basec[pos]; } } }