Ejemplo n.º 1
0
        public void SecureGram_LargeTestWithSpecificEncryptionMethodReturnCorrectValue()
        {
            string key  = RandomString();
            string salt = RandomString();

            SecureGram g = new SecureGram();

            g.Sender  = "Pinnochio";
            g.Subject = "Marionette";
            g.Message = MakeLargeTest();
            string     encrypted = g.CreateGramContent <RijndaelManaged>(key, salt);
            SecureGram decrypted = new SecureGram();

            decrypted.LoadGramContent <RijndaelManaged>(encrypted, key, salt);
            Assert.AreEqual(decrypted.Message, g.Message);
            Assert.AreEqual(decrypted.Message.Length, g.Message.Length);
            Assert.IsTrue(encrypted.Length < g.Message.Length);
            Assert.IsTrue(decrypted.IsCompressed);
            Assert.AreEqual(decrypted.Subject, g.Subject);
            Assert.AreEqual(decrypted.Sender, g.Sender);
            Assert.IsFalse(g.IsCompressed);
        }
Ejemplo n.º 2
0
        public void SecureGram_ShortTestWithDefaultEncryptionMethodReturnCorrectValue()
        {
            string key  = RandomString();
            string salt = RandomString();

            SecureGram g = new SecureGram();

            g.Sender  = "Pinnochio";
            g.Subject = "Marionette";
            g.Message = ShortTest;
            string     encrypted = g.CreateGramContent(key, salt);
            SecureGram decrypted = new SecureGram();

            decrypted.LoadGramContent(encrypted, key, salt);
            Assert.AreEqual(decrypted.Message, ShortTest);
            Assert.AreEqual(decrypted.Message.Length, ShortTest.Length);
            Assert.IsTrue(encrypted.Length > g.Message.Length);
            Assert.IsFalse(decrypted.IsCompressed);
            Assert.AreEqual(decrypted.Subject, g.Subject);
            Assert.AreEqual(decrypted.Sender, g.Sender);
            Assert.IsFalse(g.IsCompressed);
        }