0

My code below should check the working directory for the existence of test.mdb and then if it exists it should check the sha1 of MyVbs against MySha and if they’re the same it should go on to process.Start.

What code do I need to make this (if MyVbs = MySha) work? I’m using notepad to build my cs file and framework 3.5 csc.exe to compile it so please only code which is compatible with my setup. Thank you for any help.

using System;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
using System.Security.Cryptography;

    [assembly:AssemblyVersionAttribute("1.0.0.0")]
    [assembly:AssemblyTitleAttribute("MyTitle")]
    [assembly:AssemblyDescriptionAttribute("MyDescription")]
    [assembly:AssemblyCompanyAttribute("MyCompany")]
    [assembly:AssemblyFileVersionAttribute("1.0.0.0")]
    [assembly:AssemblyProductAttribute("MyProduct")]

class MyClass {
    static void Main()
 {
var filePath = @"test.mdb";
var MyVbs = @"MyScript.vbs";
var MySha = "d0be2dc421be4fcd0172e5afceea3970e2f3d940";

if (File.Exists(filePath))
{ 
if MyVbs = MySha // This needs changing to make sha1 check but how?
{ 
        Process process = new Process();
        process.StartInfo.FileName = MyVbs;
        process.Start();
}
else
{
    MessageBox.Show("The sha1 doesn't match. The file has been altered.","My Title");
}
}
else
{
    MessageBox.Show("File doesn't exist","My Title");
}
    }
}
p deman
  • 75
  • 3
  • 11
  • Hello krillgar, Phil Ross, xanatos I have seen these answers and whilst they address hashes and sha etc they are not an answer to my question which is how to make it work with my code example. I did try for three days but couldent get it to work. I am new to C# and any help to get my code to work would be appreciated – p deman Mar 13 '17 at 11:16
  • What problem are you facing with getting the code to work? Are you getting an error? As is, this does not seem seem to be a specific problem (as is generally liked in SO questions) but a "how do I make my code work?" question, which are off-topic. Basically all you need to do is take one of the linked solutions, run it on `filepath,` and then compare the result against `MySha`. – vossad01 Mar 13 '17 at 15:15

0 Answers0