示例#1
0
        public void KeyGenerateRandomness()
        {
            bool diff = false;

            using (SymmetricAlgorithm cipher = new EnigmaSymmetric())
            {
                byte[] key;
                byte[] newKey;

                cipher.GenerateKey();
                newKey = cipher.Key;
                key    = newKey;

                for (int i = 0; i < 10; i++)
                {
                    if (!newKey.SequenceEqual(key))
                    {
                        diff = true;
                        break;
                    }

                    key = newKey;
                    cipher.GenerateKey();
                    newKey = cipher.Key;
                }
            }

            Assert.True(diff);
        }
示例#2
0
        public void KeyGenerateCorrectness()
        {
            using SymmetricAlgorithm cipher = new EnigmaSymmetric();
            string keyString;

            for (int i = 0; i < 100; i++)
            {
                cipher.GenerateKey();
                keyString = Encoding.Unicode.GetString(cipher.Key);

                // Test key correctness here
                Assert.NotNull(keyString);
            }
        }