home

Easy MS Windows calculator/utility “SHA-256” 1.0.3, 2.19.2024

Gryf

JaxaSoft

Kris Jaxa
Visby, Sweden
Contact: Kris




setupSHA.exe
(size = 193390, SHA-256 = a1e2cdd120ab226b8d8615450f60c9f175921bb9a7944d86fd06602d9f9fa1da).


Program description:

SHA-256 calculator: screen dump

To check SHA-256 signature (e.g. if the file is not changed) one can use Windows certutil utility but this requires som skills, so I have made this easy calculator.

After you download your program, start this calculator, press the [File...] button and pick the program. The file's signatur will be shown in first text box.

Paste the value of SHA-256 from the source site and press [Compare] button.

Commented most important code C#:

private void PathBut_Click(object sender, RoutedEventArgs e)
    {
    var dialog = new Microsoft.Win32.OpenFileDialog();
    dialog.DefaultExt = ".exe"// Default file extension
    dialog.Filter = "Files (*.zip;*.exe)|*.zip;*.exe;|All files (*.*)|*.*";
 
    // Show open file dialog box
    boolresult = dialog.ShowDialog();
 
    // Process open file dialog box results
    if (result == true)
        {
        Res.Content = "?";
        Res.Background = Brushes.WhiteSmoke;
 
        try
            {
            // Open file dialog, choose a file to check
            string filename = dialog.FileName;
            Process oth = new Process();
            oth.StartInfo.FileName = "certutil"// program to start
            // redirect standard  output from "certutil" from screen to string
            oth.StartInfo.UseShellExecute = false;
            oth.StartInfo.RedirectStandardOutput = true;
            oth.StartInfo.CreateNoWindow = true;
            // if filname has a space we need a "", like: "some file with spaces"
            oth.StartInfo.Arguments = " -hashfile " + "\"" + filename + "\"" + " SHA256";
            //oth.EnableRaisingEvents = true;
 
            oth.Start();
            string o = oth.StandardOutput.ReadToEnd();
            // output consists of few lines, take the first with file name and
            // second with SHA-256 value
            string[] parts = o.Replace("\r""").Split('\n');
            FileName.Content = parts[0];
            Actual.Text = parts[1].Trim(); // SHA value
            }
        catch (Exception ex)
            {
            Actual.Text = "An error occurred!!!: " + ex.Message;
            }
        }
    }


home