Exemplo n.º 1
0
        public void EncryptAndDecryptAGeneratedPassword()
        {
            string randomPassword = new Password(1024).PlainText;
            string randomKey      = new Password(1024).PlainText;

            byte[] encrypted = SimpleXorEncrypter.Encrypt(randomPassword, randomKey);
            string plainText = SimpleXorEncrypter.Decrypt(encrypted, randomKey);

            Assert.AreEqual(randomPassword, plainText);
        }
Exemplo n.º 2
0
        public void EncryptPlainText()
        {
            byte[] result = SimpleXorEncrypter.Encrypt(this.plainTextMessage, SimpleXorEncrypterTest.Key);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Length, this.encryptedMessage.Length);

            for (int ix = 0; ix < this.encryptedMessage.Length; ++ix)
            {
                Assert.AreEqual(result[ix], this.encryptedMessage[ix]);
            }
        }
Exemplo n.º 3
0
        public void EncryptWithoutKey()
        {
            byte[] result = SimpleXorEncrypter.Encrypt(this.plainTextMessage, string.Empty);

            Assert.IsNull(result);
        }