예제 #1
0
        public ActionResult Upload(FileModel model)
        {
            try
            {
                if (model.PostedFile.ContentLength > 0)
                {
                    var tripleDesEncryptor = new TripleDESEncrypt(model.Key);

                    var file = new File(System.Web.HttpContext.Current);

                    var encryptedFileContent = "";
                    using (var sr = new StreamReader(model.PostedFile.InputStream))
                    {
                        encryptedFileContent = sr.ReadToEnd();
                    }

                    var decryptedValue = tripleDesEncryptor.Decrypt(encryptedFileContent);

                    file.SetFileContent(decryptedValue);
                }

                return View("Index");
            }
            catch (Exception)
            {

                ViewBag.Erro = "Esta chave é inválida";
                return View("Index");
            }

        }
예제 #2
0
        public ActionResult Upload(FileModel model)
        {
            try
            {
                if (model.PostedFile.ContentLength > 0)
                {
                    var tripleDesEncryptor = new TripleDESEncrypt(model.Key);

                    var file = new File(System.Web.HttpContext.Current);

                    var encryptedFileContent = "";
                    using (var sr = new StreamReader(model.PostedFile.InputStream))
                    {
                        encryptedFileContent = sr.ReadToEnd();
                    }

                    var decryptedValue = tripleDesEncryptor.Decrypt(encryptedFileContent);

                    file.SetFileContent(decryptedValue);
                }

                return(View("Index"));
            }
            catch (Exception)
            {
                ViewBag.Erro = "Esta chave é inválida";
                return(View("Index"));
            }
        }
예제 #3
0
        public ActionResult Download(string key)
        {
            var file = new File(System.Web.HttpContext.Current);

            var tripleDesEncryptor = new TripleDESEncrypt(key);

            var content = file.GetFileContent();

            var encryptedContent = tripleDesEncryptor.Encrypt(content);

            ViewBag.GeneratedPassword = key;

            return(File(Encoding.UTF8.GetBytes(encryptedContent), "text/plain", "encryptedPassword.txt"));
        }
예제 #4
0
        public ActionResult Download(string key)
        {
            var file = new File(System.Web.HttpContext.Current);

            var tripleDesEncryptor = new TripleDESEncrypt(key);

            var content = file.GetFileContent();

            var encryptedContent = tripleDesEncryptor.Encrypt(content);

            ViewBag.GeneratedPassword = key;

            return File(Encoding.UTF8.GetBytes(encryptedContent), "text/plain", "encryptedPassword.txt");

        }