I'm taking a cryptography course but some of the things my teacher describes are really not clear and badly explained.
He asked me to create an algorithm in Java to generate a RT table (hash/text) and to have a file (test.txt) that has 100 hashes to 'crack'. So I am at the stage where I have to compare the two files. But it seems to me too 'simple' I could look in my course and we talk about function reduction but I don't see how (when) to implement it.
I could already do the file reading and I could read line by line my big file and compare each hash with my small one. I don't know where and especially how to implement the function reduction in my algorithm and what it consists in.
Thank you very much for your help, if needed I put my code.
private static void bufferedReaderFilePasswordFirst() throws IOException {
Path path = Paths.get("C:\\Users\\basil\\OneDrive - Haute Ecole Bruxelles Brabant (HE2B)\\Documents\\NetBeansProjects\\sha256\\passwords.txt");
int nbOfLine = 0;
StringBuffer oui = new StringBuffer();
List<String> test = hashMap();
final DecimalFormat df = new DecimalFormat();
final DecimalFormatSymbols ds = df.getDecimalFormatSymbols();
ds.setGroupingSeparator('_');
df.setDecimalFormatSymbols(ds);
try (BufferedReader readerPasswordGenerate = Files.newBufferedReader(path, Charset.forName("UTF-8"));) {
String currentLinePassword = null;
long start = System.nanoTime();
while(((currentLinePassword = readerPasswordGenerate.readLine()) != null)){
String firstWord = currentLinePassword.substring(0, currentLinePassword.indexOf(":"));
int indexList = test.indexOf(firstWord);
if(indexList!=-1){
System.out.println(indexList);
String secondWord = currentLinePassword.substring(currentLinePassword.lastIndexOf(":") + 1);
oui.append(secondWord).append(System.lineSeparator());
}
nbOfLine++;
if(nbOfLine%1_000_000==0){
System.out.printf(
"%s / %s%n",
df.format(nbOfLine),
df.format(10000000));
}
}
System.out.println(oui);
final long consumed = System.nanoTime() - start;
final long totConsumed = TimeUnit.NANOSECONDS.toMillis(consumed);
final double tot = (double) totConsumed;
System.out.printf("Done. Took %s seconds", (tot / 1000));
} catch (IOException ex) {
ex.printStackTrace(); //handle an exception here
}
}
The test list is only a list of the 100 hash to crack