private void button2_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Add Key..."; ofd.Filter = "Key Files|*.pem,*.key| All files|*.*"; // if (DialogResult.OK == ofd.ShowDialog()) if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (StreamReader str = new StreamReader(@ofd.FileName)) { string fline = str.ReadLine(); if (fline.StartsWith(pemprivhead)) { privKEY = fline + "\n" + str.ReadToEnd(); } } if (privKEY == "") { MessageBox.Show("Selected File is not a Private RSA Key!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } crypter = new vxCrypt(privKEY); try { byte[] c = crypter.RSA.Encrypt(new byte[] { 0x01, 0x00 }, false); byte[] s = crypter.RSA.Decrypt(c, false); } catch { if (MessageBox.Show("There was an error loading RSA PrivateKey", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Cancel) { Environment.Exit(1); } return; } MessageBox.Show("RSA Key was successfully loaded into program!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); keyloaded = true; } if (keyloaded) { Decrypt(); } }
public vxFileManager(vxCrypt encryption) { this.encryption = encryption; }
public vxFileManager() { encryption = new vxCrypt(); }