public ActionResult Show(string guid)
        {
            var password = _repository.GetSpecific(p => p.Id == guid);

            password.Password = _caesarChipherEncryptor.Decrypt(password.Password, WordShift);

            return(View(password));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        public ActionResult Download(string publikKeyVal, string publicKey)
        {
            var passwords = _repository.GetAll();

            CaesarChipherEncryptor ce = new CaesarChipherEncryptor();

            string pass = "";

            foreach (var p in passwords)
            {
                string line = p.System + "," + p.User + "," + ce.Decrypt(p.Password, 5);

                var crypt = _rsaCrypto.Encrypt(line, new KeyValuePair <uint, uint>(uint.Parse(publikKeyVal), uint.Parse(publicKey)));

                foreach (var c in crypt)
                {
                    pass += c + " ";
                }
                pass += "\r\n";
            }

            return(File(Encoding.UTF8.GetBytes(pass), "text/plain", "rsaEncryptedPassword.csv"));
        }