Dumb Question

From: Dave Bost (dbost@solpart.com)
Date: 10/28/02


From: "Dave Bost" <dbost@solpart.com>
Date: Mon, 28 Oct 2002 16:29:32 -0600


I've spent that past 2 hours searching for answers to this quandry and I'm
tired of wasting time. Hopefully you are able to help me.

Can anyone tell me how to utilize the MD5CryptoServiceProvider class in such
a way that the computed hash equals the same hash generated from the
FormsAuthentication.HashPasswordForStoringInConfigFile() method?

Here's what I have for generating the MD5 hash through the
MD5CryptoServiceProvider:

Function MD5Hash(ByVal inputString As String) As String
    Dim myEncoder As New System.Text.UnicodeEncoding()
    Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider()
    Dim hashBytes As Byte()

    hashBytes = md5.ComputeHash(myEncoder.GetBytes(inputString))

    Return System.Convert.ToBase64String(hashBytes)
End Function

When I call the function with the string "password", I get
"sIHb6F4ew//D1OfQInQAzQ==", however the HashPasswordForStoringInConfigFile
gives me "5F4DCC3B5AA765D61D8327DEB882CF99". I'm assuming that this has to
do with either my choice of Encoding object or converting to a Base 64
string.

Any ideas?

Dave Bost



Relevant Pages

  • Re: Hash a range, output a Long Integer?
    ... I noticed that the hash value does not change if I change a cell value from ... > While Stephen's original function returns a 30 character string, ... > Dim hProv As Long ...
    (microsoft.public.excel.programming)
  • Re: making a anagram search on a wordlist
    ... Private Function FindMatch(ByVal letters As String) As String ... Dim hash As Long ...
    (microsoft.public.vb.general.discussion)
  • Field size for Hashed passwords
    ... I am using the below algorithm to hash a password to store in SQL server. ... Private Function GenerateHash(ByVal SourceText As String) As String ... Dim Ue As New UnicodeEncoding ...
    (microsoft.public.dotnet.security)
  • Field size for Hashed passwords
    ... I am using the below algorithm to hash a password to store in SQL server. ... Private Function GenerateHash(ByVal SourceText As String) As String ... Dim Ue As New UnicodeEncoding ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • MD5 hash on very large files 500mb to 4gb+
    ... I need to compute the MD5 hash on VERY large files 500mb to 4gb+ ... Private Function ComputeDataMD5(ByVal path As String) As String ... This function uses the filestream object to create the hash from, ...
    (microsoft.public.dotnet.languages.vb)