private void RSA_OAEP_Encryption_Test(String message, String label, KeyPair keyPair) { byte[] byteMessage = Encoding.UTF8.GetBytes(message); byte[] byteLabel = Encoding.UTF8.GetBytes(label); byte[] cipherText = oaep.RSAES_OAEP_Encrypt(keyPair.GetPublicKey, byteMessage, byteLabel, hash); byte[] decryptedText = oaep.RSAES_OAEP_Decrypt(keyPair.GetPrivateKey, cipherText, byteLabel, hash); CollectionAssert.AreEqual(byteMessage, decryptedText); }
public void Execute() { if (!isInitialized()) { throw new CommandNotInitializedException(); } Console.WriteLine("Decrypting..."); byte[] m = rsaes_oaep.RSAES_OAEP_Decrypt(privateKey, cipherData, label, hash); Console.WriteLine("Saving decrypted file to " + pathToDecryptedData); File.WriteAllBytes(pathToDecryptedData, m); }