Groups | Blog | Home
all groups > dotnet security > april 2007 >

dotnet security : Encrypting Data into a string


michaelloveusa NO[at]SPAM yahoo.com
4/19/2007 12:42:41 PM
Hi there.

I am trying to encrypt a connect string that has some special
characters in it (i.e. ';' and '=' and whatever other funky chars can
be in a password). So this chokes when I use the Convert.ToBase64 and
Convert.FromBase64 methods. I need the result to be a legitimate
string that I can put into a config file. Any ideas on how to best
overcome this issue?

Thanks, Mike
Joe Kaplan
4/19/2007 4:48:29 PM
Maybe you should show your code? It sounds like you have a misunderstanding
of how you should be encoding your data. Basically, you use Base64 to
represent arbitrary binary data as a string. Base64 is good for this
purpose because it can deal with binary data that doesn't have a good
natural string representation such as data with embedded nulls and other
non-printable characters. Examples of "arbitrary binary data" in the
context of crypto include encrypted data, hashes and keys.

If you have a string of plain text and need to encrypt that, you typically
want to use a text-based encoding such as UTF8 to convert that into binary.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
[quoted text, click to view]

michaelloveusa NO[at]SPAM yahoo.com
4/24/2007 9:31:29 AM
Thanks Joe.

I ended up encrypting the data and then creating a hex string (i.e.
'970BD4') from the raw data then converting it back to byte data when
I needed to decode it.

Mike

On Apr 19, 3:48 pm, "Joe Kaplan"
[quoted text, click to view]

AddThis Social Bookmark Button