storing asp.net md5 byte array in mysql
Posted: Fri 02 Sep 2011 02:45
I am attempting to store an md5 hash of a password in a mysql table.
here's the code to generate the hash:
Dim md5Hasher as New MD5CryptoServiceProvider()
Dim hashedBytes as Byte()
Dim encoder as New UTF8Encoding()
hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(somestring.text))
This produces a byte array. What is the best method of storing this byte array in mysql? Do I have to convert this to a string somehow then save? The perferred solution would be to save this in a binary field type. I'm certain this won't work..
Dim paramPwd as mysqlSqlParameter
paramPwd = New mySqlParameter("@Password", SqlDbType.Binary, 16)
paramPwd.Value = hashedBytes
here's the code to generate the hash:
Dim md5Hasher as New MD5CryptoServiceProvider()
Dim hashedBytes as Byte()
Dim encoder as New UTF8Encoding()
hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(somestring.text))
This produces a byte array. What is the best method of storing this byte array in mysql? Do I have to convert this to a string somehow then save? The perferred solution would be to save this in a binary field type. I'm certain this won't work..
Dim paramPwd as mysqlSqlParameter
paramPwd = New mySqlParameter("@Password", SqlDbType.Binary, 16)
paramPwd.Value = hashedBytes