G
Guest
I have windows application that is used to set and set passwords for a web
site.
I need to generate the MD5 hash value and store it locally. Publication is
used to update the SQL Server on the Web server.
The problem is the MD5 Hash value used in Windows does return the same Hash
used in the Web application eventhough the inputted string is the same.
I am using the following code in windows:
Private Function ConvertStringToByteArray(ByVal s As [String]) As [Byte]()
Return (New UnicodeEncoding).GetBytes(s)
End Function
Private Function HashPassword(ByVal strPasswordClear) As String
Dim dataToHash As [Byte]() = ConvertStringToByteArray(strPasswordClear)
Dim hashvalue As Byte() = CType(CryptoConfig.CreateFromName("MD5"),
HashAlgorithm).ComputeHash(dataToHash)
Return BitConverter.ToString(hashvalue)
End Function
And for the Web:
strPassword =
FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword, "md5")
How can I accomplish getting the same Hash value for both routines?
site.
I need to generate the MD5 hash value and store it locally. Publication is
used to update the SQL Server on the Web server.
The problem is the MD5 Hash value used in Windows does return the same Hash
used in the Web application eventhough the inputted string is the same.
I am using the following code in windows:
Private Function ConvertStringToByteArray(ByVal s As [String]) As [Byte]()
Return (New UnicodeEncoding).GetBytes(s)
End Function
Private Function HashPassword(ByVal strPasswordClear) As String
Dim dataToHash As [Byte]() = ConvertStringToByteArray(strPasswordClear)
Dim hashvalue As Byte() = CType(CryptoConfig.CreateFromName("MD5"),
HashAlgorithm).ComputeHash(dataToHash)
Return BitConverter.ToString(hashvalue)
End Function
And for the Web:
strPassword =
FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword, "md5")
How can I accomplish getting the same Hash value for both routines?