public void CipherEncryptsSecureString()
        {
            var    cipher          = new RijnadelEncryptionCipher();
            string encryptedResult = cipher.Encrypt(UnEncryptedText.ToSecureString(), EncryptionKey);

            Assert.AreNotEqual(UnEncryptedText, encryptedResult);
        }
        public void CipherWillEncryptSameInputToDifferenctEncrypedResult()
        {
            var    cipher           = new RijnadelEncryptionCipher();
            string encryptedResult1 = cipher.Encrypt(UnEncryptedText.ToSecureString(), EncryptionKey);
            string encryptedResult2 = cipher.Encrypt(UnEncryptedText.ToSecureString(), EncryptionKey);

            Assert.AreNotEqual(encryptedResult2, encryptedResult1);
        }
Ejemplo n.º 3
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 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);
        }
        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);
        }