public void RC2_CrossTest(string plainText) { using(var encryptor1 = new SymmetricEncryptor(new RC2CryptoServiceProvider())) using(var encryptor2 = new SymmetricEncryptor(new RC2CryptoServiceProvider())) { var plainByte1 = Encoding.Unicode.GetBytes(plainText); var plainByte2 = Encoding.Unicode.GetBytes(plainText); Assert.AreEqual(plainByte1, plainByte2); var cipher1 = encryptor1.Encrypt(plainByte1); var cipher2 = encryptor2.Encrypt(plainByte2); Assert.AreEqual(cipher1, cipher2); Assert.AreEqual(cipher1.BytesToHex(), cipher2.BytesToHex()); var clean1 = Encoding.Unicode.GetString(encryptor1.Decrypt(cipher1)); var clean2 = Encoding.Unicode.GetString(encryptor2.Decrypt(cipher2)); Assert.AreEqual(clean1, clean2); var cross1 = Encoding.Unicode.GetString(encryptor1.Decrypt(cipher2)); var cross2 = Encoding.Unicode.GetString(encryptor2.Decrypt(cipher1)); Assert.AreEqual(cross1, cross2); } }
public void RC2_CrossTest(string plainText) { using (var encryptor1 = new SymmetricEncryptor(new RC2CryptoServiceProvider())) using (var encryptor2 = new SymmetricEncryptor(new RC2CryptoServiceProvider())) { var plainByte1 = Encoding.Unicode.GetBytes(plainText); var plainByte2 = Encoding.Unicode.GetBytes(plainText); Assert.AreEqual(plainByte1, plainByte2); var cipher1 = encryptor1.Encrypt(plainByte1); var cipher2 = encryptor2.Encrypt(plainByte2); Assert.AreEqual(cipher1, cipher2); Assert.AreEqual(cipher1.BytesToHex(), cipher2.BytesToHex()); var clean1 = Encoding.Unicode.GetString(encryptor1.Decrypt(cipher1)); var clean2 = Encoding.Unicode.GetString(encryptor2.Decrypt(cipher2)); Assert.AreEqual(clean1, clean2); var cross1 = Encoding.Unicode.GetString(encryptor1.Decrypt(cipher2)); var cross2 = Encoding.Unicode.GetString(encryptor2.Decrypt(cipher1)); Assert.AreEqual(cross1, cross2); } }
public void Rijndael() { using (var encryptor = new SymmetricEncryptor(new RijndaelManaged { Mode = CipherMode.CBC })) { ValidateSymmetricEncryptor(encryptor); } }
public void TripleDES_CrossTest(string plainText) { using(var encryptor1 = new SymmetricEncryptor(new TripleDESCryptoServiceProvider())) using(var encryptor2 = new SymmetricEncryptor(new TripleDESCryptoServiceProvider())) { var bytes = Encoding.Unicode.GetBytes(plainText); var cipher1 = encryptor1.Encrypt(bytes); var cipher2 = encryptor2.Encrypt(bytes); var clean1 = Encoding.Unicode.GetString(encryptor1.Decrypt(cipher1)); var clean2 = Encoding.Unicode.GetString(encryptor2.Decrypt(cipher2)); Assert.AreEqual(clean1, clean2); var cross1 = Encoding.Unicode.GetString(encryptor1.Decrypt(cipher2)); var cross2 = Encoding.Unicode.GetString(encryptor2.Decrypt(cipher1)); Assert.AreEqual(cross1, cross2); } }
public void TripleDES_CrossTest(string plainText) { using (var encryptor1 = new SymmetricEncryptor(new TripleDESCryptoServiceProvider())) using (var encryptor2 = new SymmetricEncryptor(new TripleDESCryptoServiceProvider())) { var bytes = Encoding.Unicode.GetBytes(plainText); var cipher1 = encryptor1.Encrypt(bytes); var cipher2 = encryptor2.Encrypt(bytes); var clean1 = Encoding.Unicode.GetString(encryptor1.Decrypt(cipher1)); var clean2 = Encoding.Unicode.GetString(encryptor2.Decrypt(cipher2)); Assert.AreEqual(clean1, clean2); var cross1 = Encoding.Unicode.GetString(encryptor1.Decrypt(cipher2)); var cross2 = Encoding.Unicode.GetString(encryptor2.Decrypt(cipher1)); Assert.AreEqual(cross1, cross2); } }
public void Rijndael() { using(var encryptor = new SymmetricEncryptor(new RijndaelManaged { Mode = CipherMode.CBC })) { ValidateSymmetricEncryptor(encryptor); } }
public void DES() { using(var encryptor = new SymmetricEncryptor(new DESCryptoServiceProvider())) { ValidateSymmetricEncryptor(encryptor); } }
public void DES() { using (var encryptor = new SymmetricEncryptor(new DESCryptoServiceProvider())) { ValidateSymmetricEncryptor(encryptor); } }