-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainPage.xaml.cs
65 lines (51 loc) · 1.79 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace EncryptionDecryption
{
/// <summary>
/// The main page used to demonstrate the encryption and decryption
/// capabilities in the Universal Windows Platform
/// </summary>
public sealed partial class MainPage : Page
{
private readonly SymmetricEncryption encryptionProvider;
public MainPage()
{
this.InitializeComponent();
encryptionProvider = new SymmetricEncryption();
}
private async void Encrypt_Button_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(inputData.Text))
{
var dialog = new MessageDialog("You need to specify a string to encrypt !!");
await dialog.ShowAsync();
return;
}
var result = encryptionProvider.Encrypt(inputData.Text);
encryptedData.Text = result;
}
private async void Decrypt_Button_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(encryptedData.Text))
{
var dialog = new MessageDialog("You need to encrypt a string first !!");
await dialog.ShowAsync();
return;
}
var result = encryptionProvider.Decrypt(encryptedData.Text);
decryptedData.Text = result;
}
private void Reset_Button_Click(object sender, RoutedEventArgs e)
{
inputData.Text = string.Empty;
encryptedData.Text = string.Empty;
decryptedData.Text = string.Empty;
}
private void TextBlock_SelectionChanged(object sender, RoutedEventArgs e)
{
}
}
}