public void Aes_KeySizeExceptionTest(int keySize, string plainText) { //Arrange ICryptoEngine cryptoEngine = new AesCryptoEngine(keySize); //Act => Assert Assert.ThrowsException <ArgumentOutOfRangeException>(() => cryptoEngine.Encrypt(plainText, encryptionKey)); }
public void Aes_EncryptionDecryptionTest(int size, string plainText) { //Arrange ICryptoEngine cryptoEngine = new AesCryptoEngine(size); //Act var cipherText = cryptoEngine.Encrypt(plainText, encryptionKey); var decipher = cryptoEngine.Decrypt(cipherText, encryptionKey); //Assert Assert.AreEqual(plainText, decipher, "Encryption / Decryption failed"); }
public void Aes_Rijndael_EncryptionDecryptionTest(string plaintText) { //Arrange ICryptoEngine cryptoEngine1 = new AesCryptoEngine(); ICryptoEngine cryptoEngine2 = new RijndaelCryptoEngine(); //Act var cipherText = cryptoEngine1.Encrypt(plaintText, encryptionKey); var decipherText = cryptoEngine2.Decrypt(cipherText, encryptionKey); //Assert Assert.AreEqual(plaintText, decipherText, "Both algorithms work differe"); }
public void Aes_EncryptionTest(int keySize, string plainText) { //Arrange ICryptoEngine cryptoEngine = new AesCryptoEngine(keySize); var cipherText = cryptoEngine.Encrypt(plainText, encryptionKey); //Act var salt = cryptoEngine.GetSaltBytes(cipherText).ToArray(); var initialVectorBytes = cryptoEngine.GetInitialVectorBytes(cipherText).ToArray(); var cipherAgain = cryptoEngine.Encrypt(plainText, encryptionKey, salt, initialVectorBytes); //Assert Assert.AreEqual(cipherText, cipherAgain, "Encryption failed"); }