Exemple #1
0
        private async void ComputeHash()
        {
            if (!_loaded)
            {
                return;
            }
            try
            {
                var  selected   = (CbHash.Items[CbHash.SelectedIndex] as ComboBoxItem).Content.ToString();
                var  algo       = HashAlgorithms.MD5;
                bool convresult = Enum.TryParse <HashAlgorithms>(selected, out algo);
                hasher = new AsyncHasher(algo);
                var result = await hasher.ComputeHash(TbInput.Text);

                TbOutput.Text = AsyncHasher.HashString(result);
            }
            catch (Exception ex)
            {
                MainWindow.ErrorDialog(ex.Message);
            }
        }
Exemple #2
0
        private async void BtnStart_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                var  selected   = (CbHash.Items[CbHash.SelectedIndex] as ComboBoxItem).Content.ToString();
                var  algo       = HashAlgorithms.MD5;
                bool convresult = Enum.TryParse <HashAlgorithms>(selected, out algo);
                hasher = new AsyncHasher(algo);

                using (var fs = System.IO.File.OpenRead(InputFile.SelectedFile))
                {
                    var progressIndicator = new Progress <double>(ReportProgress);
                    var hash = await hasher.ComputeHash(fs, cts.Token, progressIndicator);

                    TbOutput.Text = AsyncHasher.HashString(hash);
                }
            }
            catch (Exception ex)
            {
                MainWindow.ErrorDialog(ex.Message);
            }
        }