Results 1 to 4 of 4

Thread: File MD5# and SHA# Calculator

Threaded View

  1. #1

    Thread Starter
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Lightbulb File MD5# and SHA# Calculator

    After seeing a long-winded version on the forums about how to generate a MD5# for a file I thought I'd post how to do this here...

    vb.net Code:
    1. Private Function CalcMD5(ByVal File As String) As String
    2.         Dim f = New IO.FileStream(File, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read, 4096)
    3.         Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
    4.         Return Join((From xItem In md5.ComputeHash(f) Select xItem.ToString("X2")).ToArray, "")
    5.     End Function

    Also you could use the following to calculate the older (and slower) SHA#:
    vb.net Code:
    1. Private Function CalcSHA(ByVal File As String) As String
    2.         Dim f = New IO.FileStream(File, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read, 4096)
    3.         Dim sha1 As New System.Security.Cryptography.SHA1CryptoServiceProvider
    4.         Return Join((From xItem In sha1.ComputeHash(f) Select xItem.ToString("X2")).ToArray, "")
    5.     End Function

    Hope this helps some people ...
    Also please provide feedback and say thanks if this helped you

    Kris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width