-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncryption.cs
38 lines (34 loc) · 978 Bytes
/
Encryption.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
using System;
using System.Security.Cryptography;
using System.Text;
using System.Security.Cryptography.X509Certificates;
namespace BITS24_C23
{
public partial class Encryption : Form
{
public Encryption()
{
InitializeComponent();
}
private void encrypt()
{
try
{
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
rsa.FromXmlString(RsaKeyTxt.Text);
byte[] encryptedData = rsa.Encrypt(Encoding.UTF8.GetBytes(InputTxt.Text), false);
OutputTxt.Text = (Convert.ToBase64String(encryptedData));
}
}
catch (Exception ex)
{
MessageBox.Show("Encryption error: " + ex.Message);
}
}
private void SubmitBtn_Click(object sender, EventArgs e)
{
encrypt();
}
}
}