コード例 #1
0
        public void EncryptFileTest()
        {
            ShiftCipher shiftCipher = new ShiftCipher();

            shiftCipher.GenKey();
            shiftCipher.Encrypt(BASE_FILE, ENC_FILE);
            TestFileEnc();
        }
コード例 #2
0
        public void EncryptStrTest()
        {
            ShiftCipher myCipher = new ShiftCipher();

            TestCtor(myCipher);
            myCipher.GenKey();
            TestStrEnc(myCipher, myCipher.Encrypt(TEST_STR));
        }
コード例 #3
0
        public void GenKeyTest()
        {
            ShiftCipher shiftCipher = new ShiftCipher();

            TestCtor(shiftCipher);
            shiftCipher.GenKey();
            Assert.AreNotEqual(0, shiftCipher.GetKey(), "key was not intialized");
        }
コード例 #4
0
        public void DecryptStrTest()
        {
            ShiftCipher myCipher = new ShiftCipher();

            TestCtor(myCipher);
            myCipher.GenKey();
            string encStr = myCipher.Encrypt(TEST_STR);

            TestStrEnc(myCipher, encStr);
            TestStrDec(encStr, myCipher.Decrypt(encStr));
        }
コード例 #5
0
        public void ROT_13_TEST()
        {
            ShiftCipher myCipher = new ShiftCipher(ShiftCipher.MODE.ROT13);

            Assert.AreEqual(ShiftCipher.MODE.ROT13, myCipher.GetMode(), "default shift mode not set correctly");
            Assert.AreEqual(0, myCipher.GetKey(), "Incorrect defualt shift amount found");
            myCipher.GenKey();
            Assert.AreEqual(ROT_13_SHIFT, myCipher.GetKey(), "Incorrect shift amount found");
            string encStr = myCipher.Encrypt(TEST_STR);

            TestStrEnc(myCipher, encStr);
            TestStrDec(encStr, myCipher.Decrypt(encStr));
        }