Solved

MySQL - VB.NET - MD5

Posted on 2010-11-15
3
638 Views
Last Modified: 2012-05-10
I'm sure this is going to be an "it's easy when you know how..." but here goes.

If I run this on a MySQL command line I get what I expect:
mysql> SELECT MD5('test text') AS strMD5;
+----------------------------------+
| strMD5                        |
+----------------------------------+
| 1e2db57dd6527ad4f8f281ab028d2c70 |
+----------------------------------+
1 row in set (0.00 sec)

However if I do this:
            strSQL = "SELECT MD5('test text') AS strMD5"
            objSQLCommand.CommandText = strSQL
            objDataAdapter = New MySqlDataAdapter()
            objDataAdapter.SelectCommand = objSQLCommand


            objDataSet = New DataSet
            objDataSet.DataSetName = "xxxx"

            objDataAdapter.Fill(objDataSet, "yyyy")

            objDataSet.WriteXml(Response.OutputStream)

I get:
<xxxx>
  <yyyy>
    <strMD5>MWUyZGI1N2RkNjUyN2FkNGY4ZjI4MWFiMDI4ZDJjNzA=</strMD5>
  </yyyy>
</xxxx>

Why is the result different?
Mike
0
Comment
Question by:Reklaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
kraiven earned 250 total points
ID: 34135784
Hi,

The value you are seeing in the .Net code is a Base64String encoding of the HEX text you are returning from the query.

E.G.
byte[] bytes = Encoding.UTF8.GetBytes ("1e2db57dd6527ad4f8f281ab028d2c70");
var outp = Convert.ToBase64String(bytes);
System.console.WriteLine(outp);

Open in new window


0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
ID: 34135828
If you output the schema, you will see a confirmation of kraiven's comment:
untitled.PNG
0
 
LVL 1

Author Closing Comment

by:Reklaw
ID: 34135864
As I said... Easy when you know how 8-)
Many thanks to you both
Mike
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question