Beispiel #1
0
 private void EncryptAndExit()
 {
     if (ShouldEncrypt)
     {
         ShouldEncrypt = false;
         string[] message           = new string[6];
         string   file_path         = Properties.Settings.Default.filepath;
         string   login_temp        = Properties.Settings.Default.login_test_file;
         string   aes_password      = GeneratePassword(8);
         GCHandle gch               = GCHandle.Alloc(aes_password, GCHandleType.Pinned);
         string   file_path_content = File.ReadAllText(file_path);
         string   tmp_file          = QuickTempFile(file_path_content);
         string   tmp_login_file    = QuickTempFile(GeneratePassword(256));
         if (File.Exists(login_temp))
         {
             File.Delete(login_temp);
         }
         AES.EncryptFile(tmp_login_file, file_path + ".login", aes_password);
         Properties.Settings.Default.login_test_file = file_path + ".login";
         Properties.Settings.Default.Save();
         AES.EncryptFile(tmp_file, file_path, aes_password);
         File.WriteAllText(tmp_file, "1010101010");
         File.Delete(tmp_file);
         message[0] = "EncryptOrDie";
         message[1] = "#------------------------------------------OneTimePassword------------------------------------#";
         message[2] = "                                       Password:"******"                            This password will be destroyed after you login.";
         message[4] = "     last btc block -> " + getLatestBitcoinBlock();
         message[5] = "#---------------------------------------------------------------------------------------------#";
         Properties.Settings.Default.aes_password_encrypted = PGP_Service.PGPEncryptMessage(message);
         Properties.Settings.Default.Save();
         ZeroMemory(gch.AddrOfPinnedObject(), aes_password.Length * 2);
         gch.Free();
         Application.Exit();
     }
     else
     {
         Application.Exit();
     }
 }
Beispiel #2
0
        private void CreateBackup()
        {
            String[] message = new string[3];
            message[0] = "EncryptOrCry - Backup";
            string fp = Properties.Settings.Default.filepath;

            if (File.Exists(fp + ".backup"))
            {
                File.Delete(fp + ".backup");
            }
            File.Copy(fp, fp + ".backup");
            string tmp = Path.GetTempPath() + Guid.NewGuid().ToString() + ".tmp";

            File.Copy(fp, tmp);
            message[1] = GeneratePassword(8);
            AES.EncryptFile(tmp, fp + ".backup", message[1]);
            if (File.Exists(fp + ".txt"))
            {
                File.Delete(fp + ".txt");
            }
            File.WriteAllText(fp + ".txt", PGP_Service.PGPEncryptMessage(message));
            File.Delete(tmp);
        }