Ejemplo n.º 1
0
 private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
 {
     MainWindow.isDecryptOpen = true;
     Cryptography cr = BinarySerialization.DeserializeCryptography(BinarySerialization.CRYPTOGRAPHY_SETTINGS);
     if (cr == null)
         cr = new Cryptography();
     cr.SetFile(openFileDialog1.FileName);
     cr.SetMode(Cryptography.DECRYPT);
     cr.RaiseFinishedDecryption += new Cryptography.FinishedDecryption(cr_OnFinishedDecryption);
     cr.DoCryptography();
     this.Visible = true;
 }
 private void okB_Click(object sender, EventArgs e)
 {
     if (passwordTB.Text.Equals(repasswordTB.Text))
     {
         passwordMismatchL.Visible = false;
         Cryptography cr = new Cryptography(passwordTB.Text, (byte)keysizeCB.SelectedIndex);
         BinarySerialization.Serialize(cr, BinarySerialization.CRYPTOGRAPHY_SETTINGS);
         this.Close();
         MainWindow.isEncryptionSettingsOpen = false;
     }
     else
         passwordMismatchL.Visible = true;
 }
 public static void Serialize(Cryptography cr, string file)
 {
     try
     {
         IFormatter formatter = new BinaryFormatter();
         Stream stream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None);
         formatter.Serialize(stream, cr);
         stream.Close();
         EncryptBin(file);
     }
     catch (Exception ex)
     {
         new Error("Cannot write to \"" + file + "\". Please check write permissions.");
     }
 }
Ejemplo n.º 4
0
 public void Backup(string file,Cryptography cryptographySettings,FTP ftpSettings,EmailNotifications emailSettings)
 {
     this.file = file;
     this.cryptographySettings = cryptographySettings;
     this.ftpSettings = ftpSettings;
     this.emailSettings = emailSettings;
     SetConnection();
     BackgroundWorker bgw = new BackgroundWorker();
     bgw.DoWork += new DoWorkEventHandler(DoBackup);
     bgw.RunWorkerAsync();
 }
Ejemplo n.º 5
0
 private void Backup()
 {
     try
     {
         Cryptography cryptographySettings = BinarySerialization.DeserializeCryptography(BinarySerialization.CRYPTOGRAPHY_SETTINGS);
         if (cryptographySettings == null)
             cryptographySettings = new Cryptography();
         FTP ftpSettings = BinarySerialization.DeserializeFTP(BinarySerialization.FTP_SETTINGS);
         if (ftpSettings == null)
             ftpSettings = new FTP();
         else
             ftpSettings = new FTP(ftpSettings.GetHost(), ftpSettings.GetPort(), ftpSettings.GetProtocol(), ftpSettings.GetFingerprint(), ftpSettings.GetUsername(), ftpSettings.GetPassword());
         Work.EmailNotifications emailSettings = BinarySerialization.DeserializeEmailNotifications(BinarySerialization.EMAIL_SETTINGS);
         if (emailSettings == null)
             emailSettings = new Work.EmailNotifications();
         ArrayList databases = BinarySerialization.DeserializeArrayList(BinarySerialization.DATABASES_ARRAYLIST);
         string[] items = myDatabasesCLB.CheckedItems.OfType<string>().ToArray();
         for (int i = 0; i < databases.Count; i++)
         {
             Database backmeup = (Database)databases[i];
             backmeup.RaiseDoingBackup += new Database.DoingBackup(db_OnDoingBackup);
             backmeup.RaiseFinished += new Database.Finished(db_OnFinished);
             for (int j = 0; j < items.Length; j++)
             {
                 if (backmeup.GetAlias().Equals(items[j]))
                 {
                     string file = MySQLBackUpFTP_ADOPSE.Properties.Settings.Default.backupPath + "\\DB_" + backmeup.GetAlias() + "_bu" + DateTime.Now.ToString("yyyyMMddHHmm") + ".sql";
                     backmeup.Backup(file, cryptographySettings, ftpSettings, emailSettings);
                 }
             }
         }
     }
     catch (Exception) { }
 }
 public static void DecryptBin(string file)
 {
     Cryptography cr = new Cryptography(Cryptography.DECRYPT, BINS_PASSWORD, file, Cryptography.KEY_128);
     cr.ForceCryptography();
 }