-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyGen.cs
48 lines (46 loc) · 1.67 KB
/
KeyGen.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace Project_v1
{
public partial class KeyGen : Form
{
public KeyGen()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int keySize = Convert.ToInt32(textBox1.Text);
string publicAndPrivateKey;
string publicKey;
string PubKeyPath = @"C:\Users\eliaszaman\Desktop\test\key\publickey.txt";
string PriKeyPath=@"C:\Users\eliaszaman\Desktop\test\key\privatekey.txt";
AsymmetricEncryption.GenerateKeys(keySize, out publicKey, out publicAndPrivateKey);
textBox2.Text = publicAndPrivateKey;
File.WriteAllText(PriKeyPath, publicAndPrivateKey);
textBox3.Text = publicKey;
File.WriteAllText(PubKeyPath, publicKey);
//string text = "text for encryptionkkkkkkkkkkk";
// string encrypted = AsymmetricEncryption.EncryptText(text, keySize, publicKey);
//string decrypted = AsymmetricEncryption.DecryptText(encrypted, keySize, publicAndPrivateKey);
//Console.WriteLine("Encrypted: {0}", encrypted);
//MessageBox.Show(encrypted);
//Console.WriteLine("Decrypted: {0}", decrypted);
//MessageBox.Show(decrypted);
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
Home hF = new Home();
hF.Show();
}
}
}