// Alicinin sertifiklarini disa aktarmasi private void buttonRecipientExport_Click(object sender, EventArgs e) { Directory.CreateDirectory(FileDirectory.Create("Sender\\") + "ReceivedCertificates\\"); ExportCertificate(dataGridViewRecipient, users); }
// RSA private key'lerin dosyadan okunmasi public RSAParameters GetPrivateKey(string dirName, Form form) { RSAParametersSerializable rsaPrivateKeyInfoSerializable = null; DirectoryInfo dirInfo = new DirectoryInfo(FileDirectory.Create(dirName) + "Keys\\"); FileInfo[] files = dirInfo.GetFiles(); foreach (FileInfo file in files) { if (file.Name.Equals(ID)) { rsaPrivateKeyInfoSerializable = Serialization.ReadFromBinaryFile <RSAParametersSerializable>(FileDirectory.Create(dirName) + "Keys\\" + ID); } } Form8Passphrase formPassphrase = new Form8Passphrase(Name); bool invalidPass = true; int tryCount = 1; while (invalidPass && tryCount <= 3) { formPassphrase.labelTry.Visible = (tryCount == 2 || tryCount == 3) ? true : false; formPassphrase.labelTry.Text = "Yanlış parola. Deneme: " + tryCount + " / 3."; formPassphrase.ShowDialog(form); byte[] passphrase = null; if (formPassphrase.DialogResult == DialogResult.OK) { passphrase = Encoding.ASCII.GetBytes(formPassphrase.textBoxPassphrase.Text); byte[] hashedInputPassphrase = SHA256Salted.GenerateSaltedHash(passphrase, salt); if (SHA256Salted.CompareByteArrays(hashedInputPassphrase, hashedPassphrase)) { rsaPrivateKeyInfoSerializable.Decrypt(passphrase); invalidPass = false; } else { invalidPass = true; tryCount++; } } else { break; } } if (tryCount > 3) { return(new RSAParameters()); } return(rsaPrivateKeyInfoSerializable.RSAParameters); }