Ejemplo n.º 1
0
        public void serializePassword()
        {
            Wotan.encrypter e = (new encrypterFactory()).create(encrypterType.AES);

            string          s       = "Hello World";
            encryptedString encrypt = new encryptedString(s);
            var             test    = encrypt.decrypted;

            using (var serializer = new contractSerializer <encryptedString>())
            {
                using (MemoryStream ms = (MemoryStream)serializer.fromObject(encrypt))
                {
                    using (StreamReader reader = new StreamReader(ms))
                    {
                        string res = reader.ReadToEnd();

                        Assert.AreEqual(res,
                                        "<encryptedString xmlns=\"http://schemas.datacontract.org/2004/07/Wotan\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                                        "<encrypt>true</encrypt>" +
                                        "<string>cybHxAg/UGmwBnuStAOaNA==</string>" +
                                        "<method>AES</method>" +
                                        "</encryptedString>");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void encrypterFactory()
        {
            var fact = new encrypterFactory();

            Wotan.encrypter e = fact.create(encrypterType.AES);

            Assert.IsInstanceOfType(e, typeof(AESEncrypter));
        }
Ejemplo n.º 3
0
        public void encryptAES()
        {
            Wotan.encrypter e = (new encrypterFactory()).create(encrypterType.AES);

            string s       = "Hello World";
            string encrypt = e.encrypt(s);
            string decrypt = e.decrypt(encrypt);

            Assert.AreEqual(decrypt, s);
        }