private void CalculateHashButton_Click(object sender, RoutedEventArgs e) { CompareHashCodeTextBox.Text = string.Empty; ClearImage(); if (OpenFileDlgTextBox.Text == String.Empty) { MessageBox.Show("Choose the file location"); } else if (File.Exists(OpenFileDlgTextBox.Text) == true) { HashProvider hashProvider = new HashProvider(OpenFileDlgTextBox.Text); switch (GetCurrentHashAlgorithm()) { case Algorithmes.CRC32: HashCodeTextBox.Text = hashProvider.GetCRCHash(); break; case Algorithmes.MD5: HashCodeTextBox.Text = hashProvider.GetMD5Hash(); break; case Algorithmes.RIPEMD160: HashCodeTextBox.Text = hashProvider.GetRIPEMD160Hash(); break; case Algorithmes.SHA1: HashCodeTextBox.Text = hashProvider.GetSHA1Hash(); break; case Algorithmes.SHA256: HashCodeTextBox.Text = hashProvider.GetSHA256Hash(); break; case Algorithmes.KECCAK224: HashCodeTextBox.Text = hashProvider.GetKeccak224Hash(); break; case Algorithmes.KECCAK256: HashCodeTextBox.Text = hashProvider.GetKeccak256Hash(); break; case Algorithmes.KECCAK384: HashCodeTextBox.Text = hashProvider.GetKeccak384Hash(); break; case Algorithmes.KECCAK512: HashCodeTextBox.Text = hashProvider.GetKeccak512Hash(); break; } } else MessageBox.Show("File does not exist"); }
private void CompareButton_Click(object sender, RoutedEventArgs e) { if (OpenFileDlgTextBox.Text == string.Empty) { browse_btn_Click(sender, e); CalculateHashButton_Click(sender, e); } if (HashCodeTextBox.Text == string.Empty) { CalculateHashButton_Click(sender, e); } if (CompareFileDialog.ShowDialog() == true) { comparingFilePath = CompareFileDialog.FileName; } if (OpenFileDlgTextBox.Text == comparingFilePath) { MessageBox.Show("The selected file is the same as the file you currently viewing"); } if (File.Exists(comparingFilePath) == true) { HashProvider hashProvider = new HashProvider(comparingFilePath); switch (GetCurrentHashAlgorithm()) { case Algorithmes.CRC32: CompareHashCodeTextBox.Text = hashProvider.GetCRCHash(); break; case Algorithmes.MD5: CompareHashCodeTextBox.Text = hashProvider.GetMD5Hash(); break; case Algorithmes.RIPEMD160: CompareHashCodeTextBox.Text = hashProvider.GetRIPEMD160Hash(); break; case Algorithmes.SHA1: CompareHashCodeTextBox.Text = hashProvider.GetSHA1Hash(); break; case Algorithmes.SHA256: CompareHashCodeTextBox.Text = hashProvider.GetSHA256Hash(); break; case Algorithmes.KECCAK224: CompareHashCodeTextBox.Text = hashProvider.GetKeccak224Hash(); break; case Algorithmes.KECCAK256: CompareHashCodeTextBox.Text = hashProvider.GetKeccak256Hash(); break; case Algorithmes.KECCAK384: CompareHashCodeTextBox.Text = hashProvider.GetKeccak384Hash(); break; case Algorithmes.KECCAK512: CompareHashCodeTextBox.Text = hashProvider.GetKeccak512Hash(); break; } if (HashCodeTextBox.Text == CompareHashCodeTextBox.Text) { SetImage(true); } else { SetImage(false); } } else MessageBox.Show("File does not exist"); }