Solved

.NET 3.5 Encrypt/Decrypt String

Posted on 2009-05-18
4
2,109 Views
Last Modified: 2013-11-08
I'm looking for functions usable in VB.NET (3.5 framework) that could be used to encrypt and decrypt stings for storage in a database. The database field is a varchar(100) and the source string will never exceed 20 characters.

We would store the key itself in a protected, central location.
0
Comment
Question by:dthansen
4 Comments
 
LVL 12

Accepted Solution

by:
GuitarRich earned 500 total points
ID: 24410909
0
 
LVL 7

Expert Comment

by:lucky_james
ID: 24411052
0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24411147
hi dthansen,
             
                   Check these links.

Simple encrypting and decrypting data in C#:

http://www.codeproject.com/KB/security/DotNetCrypto.aspx

Programmatically Encrypt and Decrypt Configuration Sections in web.config using ASP.NET 2.0 & ASP.NET 3.5:


http://www.dotnetcurry.com/ShowArticle.aspx?ID=185

How To: Encrypt and Decrypt Data Using a Symmetric (Rijndael) Key (C#/VB.NET):

http://www.obviex.com/samples/Encryption.aspx


0
 
LVL 15

Expert Comment

by:oobayly
ID: 24411216
Personally, I'd use a VARBINARY field in the database as this will prevent any encoding headaches when converting the byte array to a string. Also, as you've no need to display the encrypted data, why bother with the overhead in converting an byte array to an unreadable string?

As tapanpattanaik suggested, Rijndael (AES) is the standard to use. It uses streams to to the encryption so at the most basic level, everything's done with byte arrays. You would of course be able to use a StreamWriter to write strings to the CryptoStream when encrypting, and a StreamReader to read from CryptoStream when decrypting.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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