storing md5 byte array in mysql

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply

storing md5 byte array in mysql

Post by statik » Mon 06 Dec 2004 20:41

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

Devart Team
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Re: storing md5 byte array in mysql

Post by Oleg » Tue 07 Dec 2004 13:22

You specified the correct code cut but it is incomplete. It is not known what command you execute. Please see our Picture demo project. It demonstrates how to store binary data in database, in particular pictures.

Post Reply