Beispiel #1
0
 private void InitializeTextLoader(FileInfoModel model)
 {
     //Path
     if (Path.GetExtension(model.FilePath) == ".txt")
     {
         textLoader = new TextLoader(model.FilePath, model.GetEncoding());
     }
     else if (Path.GetExtension(model.FilePath) == ".docx")
     {
         textLoader = new DocxLoader(model.FilePath, model.GetEncoding());
     }
     //Key
     machine.Key = model.Key;
 }
Beispiel #2
0
 public IActionResult Text(RawTextModel model)
 {
     //Validate
     if (!IsKeyValid(model.Key))
     {
         ModelState.AddModelError("Invalid Key", "Invalid Key, must have only russian letters!");
     }
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     //Redirect
     textLoader  = new SimpleTextLoader(model.Text, model.Encoding);
     machine.Key = model.Key;
     if (model.Encrypt)
     {
         textLoader.Encrypt(machine);
     }
     else
     {
         textLoader.Decrypt(machine);
     }
     return(Redirect("/Action/Result"));
 }