(Something about otters)
Welcome

Simple ASP.NET Encryption Class  -  Aug 10th, 2007 1:00pm
 
I was creating an ASP.NET 2.0 web application that needed to encrypt credit card and password data.  All that I wanted/needed was a class that would allow me to specify a key and a string and it would encrypt/decrypt and return the result using decently strong (AES, TripleDES etc..) encryption.

I found a couple of things out there but nothing worked exactly as I wanted that I could either a) understand or b) see the source.  What I did find was several sites that had all created parts of what I needed so took what was out there, hit blend, added some spices and viola.  I've attached the result to this post.  Just put the class in your App_Code directory, change the passphrase to something only you know and then call it as follows:

Dim a_string As String
Dim data_encryption As DataEncryption
Dim encrypted_string As String
Dim decrypted_string As String

a_string = "hello world"
data_encryption = New DataEncryption
encrypted_string = data_encryption.encryptString(a_string)
decrypted_string = data_encryption.decryptString(encrypted_string)

Thats all there is to it, the encrypted string is base 64 encoded so its safe to print to the screen or store in textual database fields.  Hope this helps someone - if so add a comment and let me know :)


 
2KB
 

Comments

No comments have been posted yet.

Name
  (optional)
Comment
Anti-Spam

Type I am not a robot above



[ TAGS ]
- Code  (2)
- Gear  (4)
- Personal  (36)
- Signs  (3)
- Gaming  (2)
- Humor  (6)
- Fishing  (19)
- Food  (18)
- Politics  (1)
- Projects  (5)
- Travel  (17)
- Music  (6)
- Golf  (2)
- Activities  (25)




[ Eating ]
- The Arrogant Butcher - Phoenix, AZ
- Cornish Pasty Co - Chandler, AZ
- Lees Cream Liquer - Scottsdale, AZ
- Flancers - Gilbert, AZ




[ Listening To ]
- Toad The Wet Sprocket - The 90's live!
- The Appleseed Cast - Two Conversations
- The Get Up Kids - Live At Granada
- The Weakerthans - Listen to Aside
- The Faint - Wet From Birth
- Silversun Pickups - Caranvas




[ Watching ]
- Medium
- Lie To Me - Can you spot a lie?
- Thumbs Up America - A fantastic series
- Love Me If You Dare - Sooo messed up




[ Playing ]
- Final Fantasy V - (SNES)
- Sword And Sworcery - (iPad)
- Ticket To Ride - (Board)
- Settlers Of Catan - (Board Game)
- Cave Story - (PC)