public ActionResult Create(PasswordModel model)
        {
            try
            {
                model.Id       = Guid.NewGuid().ToString();
                model.Password = _caesarChipherEncryptor.Encrypt(model.Password, WordShift);
                _repository.Save(model);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(model));
            }
        }
Ejemplo n.º 2
0
        public void WhenWordIsInsertedThisWordMustBeDifferentThenBefore()
        {
            const string word = "Murilo";

            var caesarChipherEncryptor = new CaesarChipherEncryptor();

            var encryptedResult = caesarChipherEncryptor.Encrypt(word, 3);

            Assert.AreNotEqual(word, encryptedResult);
        }
Ejemplo n.º 3
0
        public void WhenWordEncryptedThenDecryptShouldBeSameWord()
        {
            const string word         = "Murilo";
            const int    displacement = 3;

            var caesarChipherEncryptor = new CaesarChipherEncryptor();

            var encryptedResult = caesarChipherEncryptor.Encrypt(word, displacement);
            var decryptedResult = caesarChipherEncryptor.Decrypt(encryptedResult, displacement);

            Assert.IsTrue(word.Equals(decryptedResult));
        }