Example #1
0
        // The plain text will be padded to fill the size of block (16 bytes), so the encoded message should be aligned with the rule
        // (text.Length % 16 == 0)
        public static void TestEncodedMessageSize(string testCase, uint key)
        {
            // Arrange
            var encoder = new FeistelCipher();

            // Assert
            Assert.Throws <ArgumentException>(() => encoder.Decode(testCase, key));
        }
Example #2
0
        public static void DecodedStringIsTheSame([Random(100)] uint key)
        {
            // Arrange
            var encoder = new FeistelCipher();
            var random  = new Randomizer();

            int lenOfString = random.Next(1000);

            string message = random.GetString(lenOfString);

            // Act
            var encoded = encoder.Encode(message, key);
            var decoded = encoder.Decode(encoded, key);

            // Assert
            Assert.AreEqual(message, decoded);
        }