Beispiel #1
0
        public ActionResult Upload(HttpPostedFileBase arquivo)
        {
            try
            {
                var content = "";

                if (arquivo.ContentLength > 0)
                {
                    var file = new Facensa.SegurancaApp.Core.Infra.File(System.Web.HttpContext.Current);

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

                    var fileLines = encryptedFileContent.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                    foreach (var l in fileLines)
                    {
                        var list = new List <uint>();
                        var a    = l.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                        foreach (var c in a)
                        {
                            list.Add((uint)int.Parse(c));
                        }

                        content += _rsaCrypto.Decrypt(list) + "\r\n";
                    }
                }

                ViewBag.content = content;

                return(View("Index"));
            }
            catch (Exception)
            {
                ViewBag.Erro = "Esta chave é inválida";
                return(View("Index"));
            }
        }
        public ActionResult Upload(HttpPostedFileBase arquivo)
        {
            try
            {
                var content = "";

                if (arquivo.ContentLength > 0)
                {

                    var file = new Facensa.SegurancaApp.Core.Infra.File(System.Web.HttpContext.Current);

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

                    var fileLines = encryptedFileContent.Split(new string[]{"\r\n"}, StringSplitOptions.RemoveEmptyEntries);

                    foreach(var l in fileLines)
                    {
                        var list = new List<uint>();
                        var a = l.Split(new string[]{" "}, StringSplitOptions.RemoveEmptyEntries);

                        foreach (var c in a)
                        {
                            list.Add((uint)int.Parse(c));
                        }

                        content += _rsaCrypto.Decrypt(list) + "\r\n";
                    }
                }

                ViewBag.content = content;

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

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

        }