I have code that encrypts a user password and stores in a database. The initial insertion occurs using a desktop application running full 2.0 .Net framework. When the user attempts to log in on a handheld device running the compact framework, I use the same code to take the supplied user password and encrypt it. I then compare that value to the database stored value and they don't match. Can anyone assist in telling me what to change to resolve this? I thought it was the encoding but no combination works to fix this. It is and always has been using ASCII encoding. The code is below:
Function EncryptToMD5String(ByVal SourceText As String) As String
'Create an encoding object to ensure the encoding standard for the source text
Dim Ue As New System.Text.ASCIIEncoding
'Retrieve a byte array based on the source text
Dim ByteSourceText() As Byte = Ue.GetBytes(SourceText)
'Instantiate an MD5 Provider object
Dim Md5 As New MD5CryptoServiceProvider
'Compute the hash value from the source
Dim ByteHash() As Byte = Md5.ComputeHash(ByteSourceText)
'And convert it to String format for return
Return Convert.ToBase64String(ByteHash)
End Function
Thanks!
Function EncryptToMD5String(ByVal SourceText As String) As String
'Create an encoding object to ensure the encoding standard for the source text
Dim Ue As New System.Text.ASCIIEncoding
'Retrieve a byte array based on the source text
Dim ByteSourceText() As Byte = Ue.GetBytes(SourceText)
'Instantiate an MD5 Provider object
Dim Md5 As New MD5CryptoServiceProvider
'Compute the hash value from the source
Dim ByteHash() As Byte = Md5.ComputeHash(ByteSourceText)
'And convert it to String format for return
Return Convert.ToBase64String(ByteHash)
End Function
Thanks!