Exemplo n.º 1
0
        public void EncryptToString_WithEmptyMessage_ReturnsEmptyString()
        {
            string    message         = String.Empty;
            Symmetric symmetricHelper = new Symmetric();
            string    actual          = symmetricHelper.EncryptToString(message);

            Assert.IsNullOrEmpty(actual);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void EncryptToString_WithNullMessage_ReturnsEmptyString()
        {
            string message = null;
            Symmetric symmetricHelper = new Symmetric();
            string actual = symmetricHelper.EncryptToString(message);

            Assert.IsNullOrEmpty(actual);
        }
Exemplo n.º 4
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);
        }