コード例 #1
0
        public void GenKeyTest()
        {
            OneTimePad cipher = new OneTimePad(TEST_STR.Length);

            TestCtor(cipher);
            cipher.GenKey();
            Assert.IsNotNull(cipher.GetKey(), "key was not intialized");
            Assert.AreEqual(TEST_STR.Length, cipher.GetKey().Length, "Incorrect KeyLen Found");
        }
コード例 #2
0
        public void SetKeyTest()
        {
            const int  KEY_LEN      = 10;
            OneTimePad encryptorOne = new OneTimePad();
            OneTimePad encryptorTwo = new OneTimePad(KEY_LEN);

            TestCtor(encryptorOne);
            TestCtor(encryptorTwo);
            encryptorTwo.GenKey();
            encryptorOne.SetKey(encryptorTwo.GetKey());
            CompareKeys(encryptorTwo.GetKey(), encryptorOne.GetKey());
        }
コード例 #3
0
 static void TestStrEnc(OneTimePad cipher, string encStr, int keyLen)
 {
     byte[] generatedKey = cipher.GetKey();
     Assert.IsNotNull(generatedKey, "Key was not Generated");
     Assert.AreNotEqual(TEST_STR, encStr, "String did not encrypt");
     Assert.AreEqual(keyLen, generatedKey.Length);
 }
コード例 #4
0
 static void TestCtor(OneTimePad cipher)
 {
     Assert.IsNull(cipher.GetKey(), "Incorrect intialized key Found");
 }