Ejemplo n.º 1
0
        public void TestAsHexNoDelimiterLower()
        {
            byte[]        before   = GetRandomBytes(200, 300);
            BinaryResults res      = new EncryptionResults(before);
            string        after    = res.AsHex(false, null);
            var           expected = new StringBuilder();

            foreach (byte b in before)
            {
                expected.Append(b.ToString("x2"));
            }
            Assert.AreEqual(expected.ToString(), after);

            res      = new DecryptionResults(before);
            after    = res.AsHex(false, null);
            expected = new StringBuilder();
            foreach (byte b in before)
            {
                expected.Append(b.ToString("x2"));
            }
            Assert.AreEqual(expected.ToString(), after);

            res      = new HashResults(before);
            after    = res.AsHex(false, null);
            expected = new StringBuilder();
            foreach (byte b in before)
            {
                expected.Append(b.ToString("x2"));
            }
            Assert.AreEqual(expected.ToString(), after);
        }
Ejemplo n.º 2
0
        public void TestAsHexDelimiterUpper()
        {
            byte[]        before   = GetRandomBytes(200, 300);
            BinaryResults res      = new EncryptionResults(before);
            string        after    = res.AsHex(true, '+');
            var           expected = new StringBuilder();

            foreach (byte b in before)
            {
                if (expected.Length > 0)
                {
                    expected.Append("+");
                }
                expected.Append(b.ToString("X2"));
            }
            Assert.AreEqual(expected.ToString(), after);

            res      = new DecryptionResults(before);
            after    = res.AsHex(true, '+');
            expected = new StringBuilder();
            foreach (byte b in before)
            {
                if (expected.Length > 0)
                {
                    expected.Append("+");
                }
                expected.Append(b.ToString("X2"));
            }
            Assert.AreEqual(expected.ToString(), after);

            res      = new HashResults(before);
            after    = res.AsHex(true, '+');
            expected = new StringBuilder();
            foreach (byte b in before)
            {
                if (expected.Length > 0)
                {
                    expected.Append("+");
                }
                expected.Append(b.ToString("X2"));
            }
            Assert.AreEqual(expected.ToString(), after);
        }