package class9_2_HashCrackingFun; // Josiah Yoder, MSOE, 06 May 2015 import java.util.Scanner; /** * This is a simple program that allows the user to enter strings, * and prints their hash codes. * * Since this is NOT a cryptographic hash, it is quite possible to * figure out what the string was from the hash. * * See challenge.txt for some output. I've not written a solution myself, * so I don't know exactly how hard it is to crack all of them, but some of the * first ones should be easy. * * Hint: as in class, look at String.hashCode's Java implementation. * * Do your required work first! Then, you might have fun with this. */ public class HashSomeStrings { public static void main(String[] args) { Scanner in = new Scanner(System.in); String text = prompt(in); while(text.length() > 0) { hash(text); text = prompt(in); } hash(text); } private static String prompt(Scanner in) { System.out.printf("Enter a string (empty string to exit):"); return in.nextLine(); } private static void hash(String text) { System.out.println("text.hashCode() = " + text.hashCode()); } }