Thomas’ Developer Blog

February 16, 2008

AES_DECRYPT non-bug bug in mySQL

Filed under: Asp.Net Framework 2.0, sql — Tags: , , , , , — sanzon @ 7:10 am

Well I ran into a small problem recently, kind of your typical issue of skipping over something small.

 When you use AES_DECRYPT in mySQL you’ll run into an issue with sending it over ASP.NET this is because .NET has some issues with BLOB types.. basically .Net doesn’t like BLOBs.

 So to fix this small error, instead of having th typical code:

Select AES_DECRYPT(column,’myKey’) As alias FROM table;

Change it to:

Select CAST(AES_DECRYPT(column,’myKey’) AS CHAR(#)) AS alias FROM table;

 All this does is cast/convert the BLOB into a char string which .NET can easily handle!  Hope this helps anyone who runs into this issue.

2 Comments »

  1. Thanks for your post, it was very helpful

    Comment by Cesar — September 29, 2008 @ 5:42 am

  2. thank you very much!!!!

    Comment by Anonymous — November 2, 2011 @ 11:32 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.