?
Solved

MySQL - VB.NET - MD5

Posted on 2010-11-15
3
Medium Priority
?
639 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 1000 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 1000 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 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