Exemplo n.º 1
0
        public void Decrypt_WithByteArraySecret_ReturnsMessage(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode)
        {
            byte[] secret   = SymmetricTestsHelper.GetDefaultSecret(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);
        }
Exemplo n.º 2
0
        public void Encrypt_WithMessage_ReturnsSecret(
            [Values(Algorithm.DES, Algorithm.TripleDES, Algorithm.RC2, Algorithm.Rijndael)] Algorithm mode)
        {
            string message = SymmetricTestsHelper.DEFAULT_MESSAGE;

            byte[] expected = SymmetricTestsHelper.GetDefaultSecret(mode);

            Symmetric symmetricHelper = new Symmetric(mode);

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

            byte[] actual = symmetricHelper.Encrypt(message);

            Assert.AreEqual(expected, actual);
        }