public void PassRSAParameter_ExportEncryptedParameterWithPrivateKey_Pass() { string plainString = "Encrypt me via RSA"; byte[] salt = { 1,2,3,4,5,6,7,8,9 }; string passwd = "SafeP4ssw0rd;,,:;DWAe"; string encryptedKey = ""; string encryptedString; string decryptedString; byte[] IV; using (var cipher = new RSACipher<RSACryptoServiceProvider>(new RSACryptoServiceProvider(2048))) { encryptedString = cipher.EncryptToString(plainString); encryptedKey = cipher.ToEncryptedXmlString<AesManaged>(true, passwd, salt, out IV); } using (var cipher = new RSACipher<RSACryptoServiceProvider>(encryptedKey, passwd, salt, IV)) { decryptedString = cipher.DecryptToString(encryptedString); } Assert.AreEqual(plainString, decryptedString); }
public void RSAParameterEncryption_ExportEncryptedParameterWithPrivateKey_Pass() { string plainKey = "soonAssigned"; byte[] salt = { 1,2,3,4,5,6,7,8,9 }; string passwd = "SafeP4ssw0rd;,,:;DWAe"; string encryptedKey = ""; string decryptedKey = "laterAssigned"; byte[] IV; using (var cipher = new RSACipher<RSACryptoServiceProvider>()) { plainKey = cipher.ToXmlString(true); encryptedKey = cipher.ToEncryptedXmlString<AesManaged>(true, passwd, salt, out IV); cipher.FromEncryptedXmlString<AesManaged>(encryptedKey, passwd, salt, IV); decryptedKey = cipher.ToXmlString(true); } Assert.AreEqual(plainKey, decryptedKey); }