java - Wordlist generator that support BigIntegers for Huge Numbers -


i need complete program generate wordlist chosen characters , length (it need support big length).

at first need fix both adding length (wordlength) wanted , making string of specified characters(alphabet).

so full number of words is:

long max_words = (long) math.pow(alphabet.length(), wordlength); 

actually, made , work (for example of short word of 2 or 66 characters).

import java.math.biginteger; public class wordlistgenenreg {  public static void main(string[] args) {  generate();  }  private static void generate(){ int wordlength =2; string alphabet = "0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.-_~"; final long max_words = (long) math.pow(alphabet.length(), wordlength); final int radix = alphabet.length();  (long = 0; < max_words; i++) {     int[] indices = converttoradix(radix, i, wordlength);     char[] word = new char[wordlength];     (int k = 0; k < wordlength; k++) {word[k] = alphabet.charat(indices[k]);}     string fullword=new string(word);     system.out.println(fullword); }  system.out.println("completed!"); }  private static int[] converttoradix(int radix, long number, int wordlength) { int[] indices = new int[wordlength]; (int = wordlength - 1; >= 0; i--) {     if (number > 0) {         int rest = (int) (number % radix);         number /= radix;         indices[i] = rest;     } else {         indices[i] = 0;     }  } return indices; } } 

but there problem when want generate big string of 64 characters 66. because:

max_words = 66^64 = 282365657377235405270307754780751252031361330095689004197961218014051357270480550051149871489969454245263206971867136

so tried change make work biginteger. result, obtain string:

"0000000000000000000000000000000000000000000000000000000000000000"

so there problem didn't figure out. work on changing it:

import java.math.biginteger;  public class wordlistgen {  public static void main(string[] args) {     generate(); }  private static void generate() { int wordlength = 64; string alphabet = "0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.-_~"; biginteger max_words=new biginteger("282365657377235405270307754780751252031361330095689004197961218014051357270480550051149871489969454245263206971867136"); final int radix = alphabet.length();  biginteger plus=biginteger.valueof(1);  (biginteger = new biginteger("0"); i.compareto(max_words) <0; i.add(plus)) {     int[] indices = converttoradix(radix, i, wordlength);     char[] word = new char[wordlength];     (int k = 0; k < wordlength; k++) {word[k] = alphabet.charat(indices[k]);}     string fullword=new string(word);     system.out.println(fullword);         } }  private static int[] converttoradix(int radix, biginteger i2, int wordlength) { biginteger zero=biginteger.valueof(0); biginteger big_radix=biginteger.valueof(radix); int[] indices = new int[wordlength]; (int = wordlength - 1; >= 0; i--) {     if (i2.compareto(zero)==0) {          biginteger rest =i2.remainder(big_radix);         biginteger ab=i2.divide(big_radix);         i2=ab;         indices[i] = rest.intvalue();     } else {         indices[i] = 0;     } } return indices; } } 

this if original version:

if (number > 0) {     int rest = (int) (number % radix);     number /= radix;     indices[i] = rest; } else {     indices[i] = 0; } 

and same if in biginteger version:

if (i2.compareto(zero)==0) {      biginteger rest =i2.remainder(big_radix);     biginteger ab=i2.divide(big_radix);     i2=ab;     indices[i] = rest.intvalue(); } else {     indices[i] = 0; } 

as can see, in new if, asking if number == 0 instead of number > 0. end in else.

as side note: running loop 0 max_words. if each iteration takes merely nanosecond complete, still take 368788667672120349090672500612638816231217766896306723928560063188563281831044121479026746095987887263264265 years. enough time universe disintegrate full entropy. i'd suggest re-thinking algorithm.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -