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
Solved

.NET 3.5 Encrypt/Decrypt String

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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