I am having a strange issue with the SHA-1 and MD5 values from files. using the below code computing the value for the same file I get the following values:
MD5 - F7ABA96EFC684E3E75EEE8C3E46DDFA
SHA-1- 714E16482F18EBDBCD6B72FC1B0536CF0DC5B72
My issue is when i compute the hash values using Microsoft's FCIV.exe tool, or other tools that compute the values they have some extra zero's that my tool does not have. here is what the FCIV.exe tool outputs.
MD5 - 0f7aba96efc684e3e75eee8c3e46ddfa
SHA-1- 714e16482f18eb0dbcd6b72fc1b0536cf0dc5b72
Does anyone know why there is an extra zero in the output from the other tools or why my code is not putting them in?
MD5
SHA-1Code:Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Not (Me.OpenFileDialog1.FileName = String.Empty) Then Dim f As New System.IO.FileStream(Me.OpenFileDialog1.FileName, IO.FileMode.Open) Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider Dim hash As Array Dim md5Hash As String Dim sb As New System.Text.StringBuilder md5.ComputeHash(f) hash = md5.Hash For Each hashByte As Byte In hash sb.Append(String.Format("{0:X1}", hashByte)) Next md5Hash = sb.ToString f.Close() Me.TextBox2.Text = sb.ToString End If End Sub
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Not (Me.OpenFileDialog1.FileName = String.Empty) Then Dim f As New System.IO.FileStream(Me.OpenFileDialog1.FileName, IO.FileMode.Open) Dim sha As New System.Security.Cryptography.SHA1CryptoServiceProvider Dim hash As Array Dim shaHash As String Dim sb As New System.Text.StringBuilder sha.ComputeHash(f) hash = sha.Hash For Each hashByte As Byte In hash sb.Append(String.Format("{0:X1}", hashByte)) Next shaHash = sb.ToString f.Close() Me.TextBox2.Text = sb.ToString End If End Sub




Reply With Quote