- Public Function GetFileMD5CheckSum(ByVal fichier As String) As String
- If IO.File.Exists(fichier) Then
- Dim st As System.IO.FileStream = Nothing
- Try
- Dim check As New System.Security.Cryptography.MD5CryptoServiceProvider
- st = System.IO.File.Open(fichier, System.IO.FileMode.Open, System.IO.FileAccess.Read)
- Dim somme As Byte() = check.ComputeHash(st)
- Dim ret As String = ""
- For Each a As Byte In somme
- If (a < 16) Then
- ret += "0" + a.ToString("X")
- Else
- ret += a.ToString("X")
- End If
- Next
- Return ret
- Catch ex As Exception
- Exit Try
- Finally
- If st IsNot Nothing Then st.Close()
- End Try
- Else
- Return ""
- End If
- Return ""
- End Function
-
- Public Function GetFileSHA1CheckSum(ByVal fichier As String) As String
- If IO.File.Exists(fichier) Then
- Dim st As System.IO.FileStream = Nothing
- Try
- Dim check As New System.Security.Cryptography.SHA1CryptoServiceProvider
- st = System.IO.File.Open(fichier, System.IO.FileMode.Open, System.IO.FileAccess.Read)
- Dim somme As Byte() = check.ComputeHash(st)
- Dim ret As String = ""
- For Each a As Byte In somme
- If (a < 16) Then
- ret += "0" + a.ToString("X")
- Else
- ret += a.ToString("X")
- End If
- Next
- Return ret
- Catch ex As Exception
- Exit Try
- Finally
- If st IsNot Nothing Then st.Close()
- End Try
- Else
- Return ""
- End If
- Return ""
- End Function
Public Function GetFileMD5CheckSum(ByVal fichier As String) As String
If IO.File.Exists(fichier) Then
Dim st As System.IO.FileStream = Nothing
Try
Dim check As New System.Security.Cryptography.MD5CryptoServiceProvider
st = System.IO.File.Open(fichier, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim somme As Byte() = check.ComputeHash(st)
Dim ret As String = ""
For Each a As Byte In somme
If (a < 16) Then
ret += "0" + a.ToString("X")
Else
ret += a.ToString("X")
End If
Next
Return ret
Catch ex As Exception
Exit Try
Finally
If st IsNot Nothing Then st.Close()
End Try
Else
Return ""
End If
Return ""
End Function
Public Function GetFileSHA1CheckSum(ByVal fichier As String) As String
If IO.File.Exists(fichier) Then
Dim st As System.IO.FileStream = Nothing
Try
Dim check As New System.Security.Cryptography.SHA1CryptoServiceProvider
st = System.IO.File.Open(fichier, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim somme As Byte() = check.ComputeHash(st)
Dim ret As String = ""
For Each a As Byte In somme
If (a < 16) Then
ret += "0" + a.ToString("X")
Else
ret += a.ToString("X")
End If
Next
Return ret
Catch ex As Exception
Exit Try
Finally
If st IsNot Nothing Then st.Close()
End Try
Else
Return ""
End If
Return ""
End Function