private void encryptBtn_Click(object sender, EventArgs e)
 {
     if (!IsEncrypted)
     {
         L2Encdec encdec = new L2Encdec();
         encdec.AttachFile(FilePath);
         string encyrptedPath = encdec.EncryptSplash();
         //TODO
     }
 }
Ejemplo n.º 2
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Task task = Task.Factory.StartNew(() =>
     {
         String dump = CreateDumpFile();
         if (dump != null && File.Exists(Application.StartupPath + "/Temp/" + dump))
         {
             String CopyFile = Application.StartupPath + "/Temp/" + Path.GetFileNameWithoutExtension(CurrentFile) + ".dump";
             File.Copy(Application.StartupPath + "/Temp/" + dump, CopyFile, true);
             SetState("Assembling Dat File");
             Chronicle chronicle = (Chronicle)Convert.ToInt32(Properties.Settings.Default.DefaultChronicle);
             L2ASM asm           = new L2ASM();
             asm.AttachFile(CopyFile);
             string assembledFile = asm.Encrypt(chronicle);
             if (assembledFile != null && File.Exists(assembledFile))
             {
                 SetState("Encoding Assembeled File..");
                 L2Encdec encdec = new L2Encdec();
                 encdec.AttachFile(assembledFile);
                 string EncryptedFile = encdec.EncryptDat();
                 if (EncryptedFile != null && File.Exists(EncryptedFile))
                 {
                     String FinalFilePath = Application.StartupPath + "/Temp/" + CurrentFile;
                     File.Copy(EncryptedFile, FinalFilePath, true);
                     SetState("Asking for Overwrite Permission...");
                     DialogResult result = MessageBox.Show("Would you Like to Overwrite the Original File ?", "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                     if (result == DialogResult.Yes)
                     {
                         File.Copy(FinalFilePath, CurrentFilePath, true);
                         SetState("File has been overwritten for you.");
                         MessageBox.Show("File Successfully Updated");
                     }
                     else if (result == DialogResult.No)
                     {
                         SetState("Asking for Saving Location ...");
                         SaveFileDialog Save = new SaveFileDialog();
                         Save.FileName       = Path.GetFileNameWithoutExtension(CurrentFile);
                         Save.Title          = "Save to ...";
                         Save.Filter         = "Data Files (*.dat)|*.dat";
                         Save.DefaultExt     = "dat";
                         DialogResult res    = Save.ShowDialog();
                         if (res == DialogResult.OK)
                         {
                             File.Copy(FinalFilePath, Save.FileName, true);
                             SetState("File Saved Successfully");
                         }
                     }
                 }
             }
         }
     });
 }
        protected void LoadFile()
        {
            if (!File.Exists(FilePath))
            {
                MessageBox.Show("Error", "Cannot Find Attached File");
                return;
            }
            L2Encdec encDec = new L2Encdec();

            encDec.AttachFile(FilePath);
            string DecryptedFile = encDec.Decrypt();

            if (!File.Exists(DecryptedFile))
            {
                MessageBox.Show("Error", "Failed to Decrypt File");
                return;
            }
            String Contents = File.ReadAllText(DecryptedFile);

            editorText.Text = Contents;
        }
 public void Attach(String bmpFile)
 {
     FilePath          = bmpFile;
     filePathText.Text = FilePath;
     try
     {
         previewBox.Image = Image.FromFile(FilePath);
         IsEncrypted      = false;
     }
     catch (Exception ex)
     {
         IsEncrypted = true;
         //Try to Encrypt
         L2Encdec encdec = new L2Encdec();
         encdec.AttachFile(FilePath);
         ModifiedPath = encdec.Decrypt();
         if (ModifiedPath != null || File.Exists(ModifiedPath))
         {
             try
             {
                 previewBox.Image = Image.FromFile(ModifiedPath);
             }
             catch (Exception ex2)
             {
                 MessageBox.Show("Malformed BMP File", "Error");
                 return;
             }
         }
     }
     finally
     {
         stateLabel.Text    = (IsEncrypted) ? "Encrypted" : "Decrypted";
         encryptBtn.Enabled = !IsEncrypted;
         decryptBtn.Enabled = IsEncrypted;
         //Transparent Key
         Bitmap bitmap = ((Bitmap)previewBox.Image);
         bitmap.MakeTransparent(Color.FromArgb(0, 255, 0));
         previewBox.Image = bitmap;
     }
 }
Ejemplo n.º 5
0
        public void LoadFile(String filePath)
        {
            L2Encdec encrypter = new L2Encdec();

            try
            {
                CurrentFilePath       = filePath;
                CurrentFile           = Path.GetFileName(filePath);
                currentFileLabel.Text = CurrentFile;
                encrypter.AttachFile(filePath);
                string decryptedFile = encrypter.Decrypt();
                if (decryptedFile != null)
                {
                    L2ASM asm = new L2ASM();
                    asm.AttachFile(decryptedFile);
                    String txtFile = asm.Decrypt((Chronicle)chronicleCombo.SelectedIndex);
                    if (txtFile != null)
                    {
                        ParseTextFile(txtFile);
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }