Solved

MySQL - VB.NET - MD5

Posted on 2010-11-15
3
637 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

696 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