Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=blue]Imports System.Security.Cryptography
Imports System.IO
Public Class Form1
Public Enum HashOption
hashMD5
hashSHA1
hashSHA256
hashSHA512
End Enum
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox.Show(filehash("d:\downloads\deleteme\test.txt", HashOption.hashSHA256))
End Sub
Function filehash(file_name As String, Optional hashmethod As HashOption = HashOption.hashSHA512) As String
Dim hash
Dim hashValue() As Byte
Dim fileStream As FileStream = File.OpenRead(file_name)
fileStream.Position = 0
[COLOR=green]' There are multiple ways of selecting the desired hashing algorithm
' This is just one[/color]
Select Case hashmethod
Case HashOption.hashMD5
hash = MD5.Create()
Case HashOption.hashSHA1
hash = SHA1.Create()
Case HashOption.hashSHA256
hash = SHA256.Create()
Case HashOption.hashSHA512
hash = SHA512.Create()
Case Else
End Select
hashValue = hash.ComputeHash(fileStream)
Dim hash_hex = Convert.ToHexString(hashValue)
fileStream.Close()
filehash = hash_hex
End Function
End Class[/color]
StrongM said:can I just check - did my solution work for you?