public void CipherUsesDifferentIVForEachEncryption()
        {
            var    cipher           = new RijnadelEncryptionCipher();
            string encryptedResult1 = cipher.Encrypt(UnEncryptedText.ToSecureString(), EncryptionKey);
            string encryptedResult2 = cipher.Encrypt(UnEncryptedText.ToSecureString(), EncryptionKey);

            byte[] iv1 = cipher.GetIV(encryptedResult1);
            byte[] iv2 = cipher.GetIV(encryptedResult2);

            Assert.AreNotEqual(iv1, iv2);
        }
Esempio n. 2
0
        //[TestMethod]
        public void Login()
        {
            var cipher = new RijnadelEncryptionCipher();

            string hashedPassword = cipher.Encrypt(CorrectPassword.ToSecureString(), EncryptionKey);

            byte[] salt = cipher.GetSalt(hashedPassword);
            byte[] iv   = cipher.GetIV(hashedPassword);

            string result = cipher.Encrypt(CorrectPassword.ToSecureString(), EncryptionKey, salt, iv);
        }
        public void CipherWillEncryptSameInputToSameResultGivenSaltAndIV()
        {
            var    cipher           = new RijnadelEncryptionCipher();
            string encryptedResult1 = cipher.Encrypt(UnEncryptedText.ToSecureString(), EncryptionKey);

            byte[] salt = cipher.GetSalt(encryptedResult1);
            byte[] iv   = cipher.GetIV(encryptedResult1);

            string encryptedResult2 = cipher.Encrypt(UnEncryptedText.ToSecureString(), EncryptionKey, salt, iv);

            Assert.AreEqual(encryptedResult1, encryptedResult2);
        }