Living in Code

Ramblings from a code monkey


VB.NET RC4 Encryption for database storage

I recently had to upgrade some Classic ASP code to .NET for some data encryption.  The routines use RC4 encryption and make the result database friendly.  The following class can easily be dropped into your project for use with little effort.  The sample code shows the encryption and decryption methods.  You just provide the message and the key for either instance.  From there you can drop it in your database or do whatever you want!

Sample Usage:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim plainText As String = "I'm exposed!"
        Dim passkey As String = "keep me safe"

        Dim safeText As String
        safeText = Common.Encryption.Encrypt(plainText, passkey)

        Response.Write(safeText)

        Dim decrypted As String
        decrypted = Common.Encryption.Decrypt(safeText, passkey)

        Response.Write(decrypted)

    End Sub

 You can view the entire class here.  If you're looking for some quick and easy encryption this will do the trick.

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Don on Wednesday, November 28, 2007
Permalink | Comments (2) | Post RSSRSS comment feed

Comments

DotNetKicks.com

Tuesday, November 27, 2007 11:32 PM

trackback

Trackback from DotNetKicks.com

VB.NET RC4 Encryption for database storage

andy us

Sunday, February 03, 2008 10:23 AM

Gravatar

perfect.. best RC4 implementaion for VB.NET!

Add comment


(Will show your Gravatar icon)  

  Country flag




Live preview

Wednesday, January 07, 2009 4:03 AM

Gravatar