public void GetCollisions(string hash, ConcurrentQueue <string> buffer) { //decimal i = 0; do { if (buffer == null) { Thread.Sleep(5); } else { string woord; bool test = buffer.TryDequeue(out woord); if (!test) { //Stalled(); Thread.Sleep(5); } hashwoord = MD5Calculator.GetHash(woord); Console.WriteLine(hashwoord); if (hash.Equals(hashwoord)) { CollisionFound(woord); } //i++; //ProgressChanged(i); } } while (!stop); }
/// <summary> /// Defines the method that calculates and displays all hashes. /// </summary> private void Calculate() { CleanUpHashValues(); if (File.Exists(filePath)) { try { MD5Calculator mD5 = new MD5Calculator(filePath); MD5Hash = mD5.Calculate(); SHA256Calculator sHA256 = new SHA256Calculator(filePath); SHA256Hash = sHA256.Calculate(); SHA512Calculator sHA512 = new SHA512Calculator(filePath); SHA512Hash = sHA512.Calculate(); } catch (IOException e) { MessageBox.Show(e.Message, "Hashing", MessageBoxButton.OK, MessageBoxImage.Error); } catch (UnauthorizedAccessException e) { MessageBox.Show(e.Message, "Hashing", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void MD5Calculator_DoWork(object sender, DoWorkEventArgs e) { byte[] buffer; int bytesRead; long size; long totalBytesRead = 0; using (Stream file = File.OpenRead(patchPath)) { size = file.Length; using (HashAlgorithm hasher = MD5.Create()) { do { buffer = new byte[4096]; bytesRead = file.Read(buffer, 0, buffer.Length); totalBytesRead += bytesRead; hasher.TransformBlock(buffer, 0, bytesRead, null, 0); MD5Calculator.ReportProgress((int)(totalBytesRead * 1D / size * 100)); }while (bytesRead != 0); hasher.TransformFinalBlock(buffer, 0, 0); e.Result = MakeHashString(hasher.Hash); } } }
private void buttonStart_Click(object sender, EventArgs e) { //mcc.ProgressChanged += ProgressHandler; mcc.CollisionFound += CollisionHandler; String hash = MD5Calculator.GetHash(textBox1.Text.ToUpper()); mcc.StartCalculatingMD5Collision(hash, (int)UpDown.Value); //mcc.ProgressChanged -= ProgressHandler; }
private void patchDialog_FileOk(object sender, CancelEventArgs e) { textBoxPatchFile.Text = patchDialog.FileName; patchPath = patchDialog.FileName; progressBar1.Visible = true; textBoxPatchFileMd5.Text = ""; FileInfo fi = new FileInfo(patchPath); textBoxPatchFileSize.Text = fi.Length.ToString(); this.Enabled = false; MD5Calculator.RunWorkerAsync(); }
public void StartCalculatingMD5Collision(string hash, int passwordLength) { var generator = new PasswordGenerator(passwordLength); int count = 0; foreach (var password in generator) { Console.WriteLine($"{password}"); count++; if (MD5Calculator.GetHash(password) == hash) { CollisionFoundHandler(password); break; } ProgressChangedHandler(count); } }
static void Main(string[] args) { string passWord = "******"; String hash = MD5Calculator.GetHash(passWord); Console.WriteLine($"Hash voor '{passWord}' = {hash}"); var generator = new PasswordGenerator(8); Console.WriteLine($"\nAantal paswoorden van 8 hoofdletters: {generator.Count():N0}"); Console.WriteLine($"\nEerste 10 paswoorden van 8 hoofdletters:\n"); int count = 0; foreach (var password in generator) { Console.WriteLine($"{password}"); count++; if (count == 10) { break; } } icc.CollisionFound += CollisionHandler; icc.StartCalculatingMD5Collision(hash, 3); Console.WriteLine("\n\nPress <enter> to end"); Console.ReadLine(); }
private void button1_Click(object sender, EventArgs e) { password = textBoxPassword.Text.Trim(); hash = MD5Calculator.GetHash(password); textBoxHash.Text = hash; }