public void CrossTest(string plainText) { using (var encryptor1 = new AriaSymmetricEncryptor()) using (var encryptor2 = new AriaSymmetricEncryptor()) { 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 = StringTool.GetString(Encoding.Unicode, encryptor1.Decrypt(cipher1)); var clean2 = StringTool.GetString(Encoding.Unicode, encryptor2.Decrypt(cipher2)); Assert.AreEqual(clean1, clean2); var cross1 = StringTool.GetString(Encoding.Unicode, encryptor1.Decrypt(cipher2)); var cross2 = StringTool.GetString(Encoding.Unicode, encryptor2.Decrypt(cipher1)); Assert.AreEqual(cross1, cross2); } }
public void SetUp() { _aria = new AriaSymmetricEncryptor(); }