Exemplo n.º 1
0
        public void XCryptTest()
        {
            byte[] key = Encoding.UTF8.GetBytes("12345");

            XCrypt crypt = new XCrypt(key);

            Assert.AreEqual(key, crypt.Key);
        }
Exemplo n.º 2
0
        public void DecryptTest_EmptyKey()
        {
            byte[] key   = new byte[0];
            XCrypt crypt = new XCrypt(key);

            byte[] cipherText = Encoding.UTF8.GetBytes("BS^DYT");

            Assert.Throws <InvalidOperationException>(() => crypt.Decrypt(cipherText));
        }
Exemplo n.º 3
0
        public void EncryptTest_EmptyKey()
        {
            byte[] key   = new byte[0];
            XCrypt crypt = new XCrypt(key);

            byte[] plainText = Encoding.UTF8.GetBytes("sample");

            Assert.Throws <InvalidOperationException>(() => crypt.Encrypt(plainText));
        }
Exemplo n.º 4
0
        public void DecryptTest()
        {
            byte[] key   = Encoding.UTF8.GetBytes("12345");
            XCrypt crypt = new XCrypt(key);

            byte[] cipherText = Encoding.UTF8.GetBytes("BS^DYT");
            byte[] expected   = Encoding.UTF8.GetBytes("sample");

            byte[] actual = crypt.Decrypt(cipherText);

            CollectionAssert.AreEqual(expected, actual);
        }