Solved

.NET 3.5 Encrypt/Decrypt String

Posted on 2009-05-18
4
2,118 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
[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
4 Comments
 
LVL 12

Accepted Solution

by:
GuitarRich earned 500 total points
ID: 24410909
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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

690 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