Solved

.NET 3.5 Encrypt/Decrypt String

Posted on 2009-05-18
4
2,103 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net checkbox 7 41
Class object 2 26
.Net Web Site IIS Web.Config Content-Security-Policy 1 34
Visual Studio TFS - how do I check in my code? 2 28
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now