Пример #1
0
        public void Decrypt_WithEmptyString_ReturnsEmptyString(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode)
        {
            string secret = String.Empty;

            Symmetric symmetricHelper = new Symmetric(mode);

            symmetricHelper.Salt = SymmetricTestsHelper.DEFAULT_SALT;
            symmetricHelper.IV   = SymmetricTestsHelper.GetDefaultIV(mode);
            symmetricHelper.Key  = SymmetricTestsHelper.GetDefaultKey(mode);

            string actual = symmetricHelper.Decrypt(secret);

            Assert.IsNullOrEmpty(actual);
        }
Пример #2
0
        public void Decrypt_WithDefaultSecretString_ReturnsEmptyString(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode)
        {
            string secret   = SymmetricTestsHelper.GetDefaultSecretString(mode);
            string expected = SymmetricTestsHelper.DEFAULT_MESSAGE;

            Symmetric symmetricHelper = new Symmetric(mode);

            symmetricHelper.Salt = SymmetricTestsHelper.DEFAULT_SALT;
            symmetricHelper.IV   = SymmetricTestsHelper.GetDefaultIV(mode);
            symmetricHelper.Key  = SymmetricTestsHelper.GetDefaultKey(mode);

            string actual = symmetricHelper.Decrypt(secret);

            Assert.AreEqual(expected, actual);
        }
Пример #3
0
        public void EncryptToString_WithMessage_ReturnsSecret(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode)
        {
            string message  = SymmetricTestsHelper.DEFAULT_MESSAGE;
            string expected = SymmetricTestsHelper.GetDefaultSecretString(mode);

            Symmetric symmetricHelper = new Symmetric(mode);

            symmetricHelper.Salt = SymmetricTestsHelper.DEFAULT_SALT;
            symmetricHelper.IV   = SymmetricTestsHelper.GetDefaultIV(mode);
            symmetricHelper.Key  = SymmetricTestsHelper.GetDefaultKey(mode);

            string actual = symmetricHelper.EncryptToString(message);

            Assert.AreEqual(expected, actual);
        }