Triple DES Encryption and Decryption In WPF

No.of Views1195
Bookmarked0 times
Downloads 
Votes1
By  dpatra   On  23 Apr 2010 10:04:54
Tag : WPF , Security
In this article we will see how a set of data can be encrypted and saved in file and again while reading it should be readable/decrypted based on key.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

In this article we will see how a set of data can be encrypted and saved in file and again while reading it should be readable/decrypted based on key.


Creating WPF Application Project

Fire up Visual Studio 2008 and Create a WPF Application and name the project as CryptographyInWPF.

 

Image Loading

Here is the basic idea about this sample application. We will add User details and saved to the file, but it would be accessible based on key.
We need to use the following namespace:
 

Image Loading

Add the above to the Window1.xaml.cs,First we will create a class that would help us storing User Data.


 

Image Loading

Now we will design the Window interface. Nothing much but we need a DataGrid and few Buttons and TextBoxes. The following figure will give you the design.

 

Image Loading

Before writing any other lines of code let me first intoduce you to the Encryption and Decryption methods as follows:

 

Image Loading

I have added an xml file which will be copied to the output Directory once build. The following is the setting for that.

 

Image Loading

The following method LoadData() will load the data from the xml file and populate into the DataGrid.

 

Image Loading

For Add operation we need to have the below methods and events that would help us achieving the Add Operation successfully.

 

Image Loading

 

Image Loading

It Seems we are done with the code, now we can test the application. Following are few screenshots when we add or read/load the data from xml file.

 

Image Loading

 

Image Loading
 
Image Loading

You won’t feel the difference but if you open the file in the following path you would see that the xml content is encrypted.

 

Image Loading
 
Image Loading

Conclusion

In this article i have explained work woh triple DES encrptyion in Windows presentation foundation.

Sample Project Source

Download source files -540 kb

 
Sign Up to vote for this article
 
About Author
 
dpatra
Occupation-Not Provided
Company-Not Provided
Member Type-Expert
Location-Not Provided
Joined date-13 Jul 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top