private void EncryptClick(object sender, EventArgs e) { var N = (uint)numericUpDownN.Value; var E = (uint)numericUpDownE.Value; var destinationFilePath = $"{textBoxFilePathSource.Text}.rsa"; using (var fileReader = new FileReader(textBoxFilePathSource.Text, new Buffer())) { using (var fileWriter = new FileWriter(destinationFilePath, new Buffer())) { rsaEncrypter.EncryptFile(fileReader, fileWriter, N, E); } } if (checkBoxShowKeysEncrypting.Checked) { DisplayKeys(rsaEncrypter.KeysFromLastRun, textBoxKeysEncrypt); } }
public void FileIsEncryptedThenDecryptedCorrectly() { using (var fileReader = new FileReader(filePathSource, new Buffer())) { using (var fileWriter = new FileWriter(filePathEncryptedFile, new Buffer())) { rsaEncrypter.EncryptFile(fileReader, fileWriter, Constants.N, Constants.E); } } using (var fileReader = new FileReader(filePathEncryptedFile, new Buffer())) { using (var fileWriter = new FileWriter(filePathDecryptedFile, new Buffer())) { rsaDecrypter.DecryptFile(fileReader, fileWriter, Constants.D); } } Assert.IsTrue(TestMethods.FilesHaveTheSameContent(filePathSource, filePathDecryptedFile)); }