/* * // Function down below is way much faster than this. * static List<Md5Pair> loadWordList(string path) * { * List<Md5Pair> list = new List<Md5Pair>(); * string[] lines = System.IO.File.ReadAllLines(string.Format(@"{0}", path)); * foreach (string line in lines) * { * string[] parts = line.Split(','); * Md5Pair pair = new Md5Pair(); * pair.Md5 = parts[0]; * pair.word = parts[1]; * list.Add(pair); * } * return list; * } */ static List <Md5Pair> loadWordList(string path) { List <Md5Pair> list = new List <Md5Pair>(); using (FileStream fs = File.OpenRead(path)) using (BufferedStream bs = new BufferedStream(fs)) using (StreamReader sr = new StreamReader(bs)) { string s; while ((s = sr.ReadLine()) != null) { string[] parts = s.Split(','); Md5Pair pair = new Md5Pair(); pair.Md5 = parts[0]; pair.word = parts[1]; list.Add(pair); } } return(list); }
static void printSearchResult(string md5) { DateTime start = DateTime.Now; Md5Pair pair = find(md5); if (pair == null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Not Found: " + md5); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(string.Format("Found: {0} = ({1})", md5, pair.word)); } DateTime end = DateTime.Now; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Time Elapsed: " + (end - start).TotalSeconds + " secs"); Console.ForegroundColor = ConsoleColor.Gray; }