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"); }
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()); }
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); }
static void TestCtor(OneTimePad cipher) { Assert.IsNull(cipher.GetKey(), "Incorrect intialized key Found"); }