コード例 #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);
        }
コード例 #2
0
        public void TestAsAscii85()
        {
            byte[]        before = GetRandomBytes(200, 300);
            BinaryResults res    = new EncryptionResults(before);
            string        after  = res.AsAscii85();

            Assert.IsTrue(Ascii85Converter.BytesToAscii85(before).SequenceEqual(after));

            res   = new DecryptionResults(before);
            after = res.AsAscii85();
            Assert.IsTrue(Ascii85Converter.BytesToAscii85(before).SequenceEqual(after));

            res   = new HashResults(before);
            after = res.AsAscii85();
            Assert.IsTrue(Ascii85Converter.BytesToAscii85(before).SequenceEqual(after));
        }
コード例 #3
0
        public void TestAsBase64()
        {
            byte[]        before = GetRandomBytes(200, 300);
            BinaryResults res    = new EncryptionResults(before);
            string        after  = res.AsBase64();

            Assert.IsTrue(Convert.ToBase64String(before).SequenceEqual(after));

            res   = new DecryptionResults(before);
            after = res.AsBase64();
            Assert.IsTrue(Convert.ToBase64String(before).SequenceEqual(after));

            res   = new HashResults(before);
            after = res.AsBase64();
            Assert.IsTrue(Convert.ToBase64String(before).SequenceEqual(after));
        }
コード例 #4
0
        public void TestAsBytes()
        {
            byte[]        before = GetRandomBytes(200, 300);
            BinaryResults res    = new EncryptionResults(before);

            byte[] after = res.AsBytes();
            Assert.IsTrue(before.SequenceEqual(after));

            res   = new DecryptionResults(before);
            after = res.AsBytes();
            Assert.IsTrue(before.SequenceEqual(after));

            res   = new HashResults(before);
            after = res.AsBytes();
            Assert.IsTrue(before.SequenceEqual(after));
        }
コード例 #5
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);
        }