private void ChecksumVerificationButton_Click(object sender, RoutedEventArgs e) { ChecksumVerificationButton.IsEnabled = false; string filePath = FilePathBox.Text; if (!GetAndValidateFile.ValidateFilePath(filePath)) { return; } Checksum.HashingAlgoTypes selectedAlgo = FuntionBundle.IntToHashType(AlgoSelectorBox.SelectedIndex, filePath); //GenerateChecksum for file string GeneratedChecksum = Checksum.GenerateChecksumAsync(selectedAlgo, filePath).GetAwaiter().GetResult(); CalculatedChecksumBlock.Text = GeneratedChecksum.ToLower(); if (GeneratedChecksum.ToLower() == ChecksumTextBox.Text) { MessageBox.Show("Checksum is correct", "Result", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Checksum is not correct", "Result", MessageBoxButton.OK, MessageBoxImage.Information); } ChecksumVerificationButton.IsEnabled = true; }
public static Checksum.HashingAlgoTypes IntToHashType(int index, string filePath) { Checksum.HashingAlgoTypes selectedAlgo = Checksum.HashingAlgoTypes.MD5; //Get selected algo switch (index) { case 0: selectedAlgo = Checksum.HashingAlgoTypes.MD5; break; case 1: selectedAlgo = Checksum.HashingAlgoTypes.SHA1; break; case 2: selectedAlgo = Checksum.HashingAlgoTypes.SHA256; break; case 3: selectedAlgo = Checksum.HashingAlgoTypes.SHA384; break; case 4: selectedAlgo = Checksum.HashingAlgoTypes.SHA512; break; } return(selectedAlgo); }
private void GenerateChecksumButton_Click(object sender, RoutedEventArgs e) { string filePath = FilePathTextBox1.Text; if (!GetAndValidateFile.ValidateFilePath(filePath)) { return; } Checksum.HashingAlgoTypes selectedAlgo = FuntionBundle.IntToHashType(AlgoSelectorBox.SelectedIndex, filePath); //GenerateChecksum for file string GeneratedChecksum = Checksum.GenerateChecksumAsync(selectedAlgo, filePath).GetAwaiter().GetResult(); CheckSumBox1.Text = GeneratedChecksum.ToLower(); }