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.
IntroductionIn 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.Crating WPF Application ProjectFire up Visual Studio 2008 and Create a WPF Application and name the project as CryptographyInWPF.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:Add the above to the Window1.xaml.cs.First we will create a class that would help us storing User Data.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.Before writing any other lines of code let me first intoduce you to the Encryption and Decryption methods as follows:I have added an xml file which will be copied to the output Directory once build. The following is the setting for that.The following method LoadData() will load the data from the xml file and populate into the DataGrid.For Add operation we need to have the below methods and events that would help us achieving the Add Operation successfully.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.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.
WPF Simplified: Build Windows Apps Using C# and XAML