Пример #1
0
		private void checkBoxMyDecodePasswordKeep_CheckedChanged(object sender, EventArgs e)
		{
			if (fLoading == true)
			{
				return;
			}

			if (checkBoxMyDecodePasswordKeep.Checked == true)
			{
				// Show Option form
				Form4 frm4 = new Form4("DecryptPassword", "");
				frm4.ShowDialog();
				frm4.Dispose();

				if (AppSettings.Instance.MyDecryptPasswordString == "")
				{
					textBoxMyDecodePassword.Text = "";
					checkBoxMyDecodePasswordKeep.Checked = false;

          if (checkBoxMyEncodePasswordKeep.Checked == false)
          {
            checkBoxDobyMemorizedPassword.Checked = false;
            checkBoxDobyMemorizedPassword.Enabled = false;
          }
        }
				else
				{
					//textBoxMyEncodePassword.Text = new string('*', AppSettings.Instance.MyEncryptPasswordString.Length);
					textBoxMyDecodePassword.Text = new string('*', 16);

          //checkBoxDobyMemorizedPassword.Checked = true;
          checkBoxDobyMemorizedPassword.Enabled = true;
        }
      }

      buttonApply.Enabled = true;

		}
Пример #2
0
        private void StartProcess()
        {
            int ProcessType = 0;
              TempOverWriteOption = -1;

              labelPassword.Text = Resources.labelPassword;
              labelInputPasswordAgain.Text = Resources.labelInputPasswordAgainToConfirm;

              textBoxPassword.Enabled = true;
              textBoxPassword.BackColor = SystemColors.Window;
              textBoxPassword.Text = "";
              textBoxRePassword.Enabled = true;
              textBoxRePassword.BackColor = SystemColors.Window;
              textBoxRePassword.Text = "";
              AppSettings.Instance.MyEncryptPasswordBinary = null;

              // self-executable file
              if (AppSettings.Instance.fSaveToExeout == true)
              {
            ProcessType = PROCESS_TYPE_ATC_EXE;
            AppSettings.Instance.EncryptionFileType = FILE_TYPE_ATC_EXE;
              }

              // 明示的な暗号処理、または復号処理
              // Explicit encryption or decryption?
              if (AppSettings.Instance.ProcTypeWithoutAsk > 0)
              {
            if (AppSettings.Instance.ProcTypeWithoutAsk == 1) // Encryption
            {
              panelStartPage.Visible = false;
              panelEncrypt.Visible = true;        // Encrypt
              textBoxPassword.Focus();            // Text box is focused
              panelEncryptConfirm.Visible = false;
              panelDecrypt.Visible = false;
              panelProgressState.Visible = false;

            }
            else if(AppSettings.Instance.ProcTypeWithoutAsk == 2) // Decryption
            {
              panelStartPage.Visible = false;
              panelEncrypt.Visible = false;
              panelEncryptConfirm.Visible = false;
              panelDecrypt.Visible = true;        // Decrypt
              textBoxDecryptPassword.Focus();     // Text box is focused
              panelProgressState.Visible = false;
            }

              }
              // 内容にかかわらず暗号化か復号かを問い合わせる
              // Ask to encrypt or decrypt regardless of contents.
              else if (AppSettings.Instance.FileList.Count() > 0 && AppSettings.Instance.fAskEncDecode == true)
              {
            Form4 frm4 = new Form4("AskEncryptOrDecrypt", "");
            frm4.ShowDialog();
            int ProcessNum = frm4.AskEncryptOrDecrypt;  // 1: Encryption, 2: Decryption, -1: Cancel
            frm4.Dispose();

            //-----------------------------------
            // Encryption
            //-----------------------------------
            if (ProcessNum == 1)
            {
              panelStartPage.Visible = false;
              panelEncrypt.Visible = true;        // Encrypt
              textBoxPassword.Focus();            // Text box is focused
              panelEncryptConfirm.Visible = false;
              panelDecrypt.Visible = false;
              panelProgressState.Visible = false;
            }
            //-----------------------------------
            // Decryption
            //-----------------------------------
            else if (ProcessNum == 2)
            {
              panelStartPage.Visible = false;
              panelEncrypt.Visible = false;
              panelEncryptConfirm.Visible = false;
              panelDecrypt.Visible = true;        // Decrypt
              textBoxDecryptPassword.Focus();     // Text box is focused
              panelProgressState.Visible = false;
            }
            //-----------------------------------
            // Cancel
            //-----------------------------------
            else
            {
              this.BackColor = Color.White;
              return;
            }

              }
              else
              {
            //----------------------------------------------------------------------
            // 問い合わせず自動判別する
            // Auto detect without asking user

            // File type
            // private const int FILE_TYPE_ERROR        = -1;
            // private const int FILE_TYPE_NONE         = 0;
            // private const int FILE_TYPE_ATC          = 1;
            // private const int FILE_TYPE_ATC_EXE      = 2;
            // private const int FILE_TYPE_PASSWORD_ZIP = 3;
            //
            // -----------------------------------
            //
            // Process Type
            // private const int PROCESS_TYPE_ERROR        = -1;
            // private const int PROCESS_TYPE_NONE         = 0;
            // private const int PROCESS_TYPE_ATC          = 1;
            // private const int PROCESS_TYPE_ATC_EXE      = 2;
            // private const int PROCESS_TYPE_PASSWORD_ZIP = 3;
            // private const int PROCESS_TYPE_DECRYPTION   = 4;

            ProcessType = AppSettings.Instance.EncryptionSameFileTypeBefore;

            if (AppSettings.Instance.EncryptionSameFileTypeAlways > 0)
            {
              ProcessType = AppSettings.Instance.EncryptionSameFileTypeAlways;
            }

            // Specified file type
            if (ProcessType > 0)
            {
              // Detect file type
              int AtcProcessType = AppSettings.Instance.DetectFileType();

              if (AtcProcessType == PROCESS_TYPE_DECRYPTION)
              {
            ProcessType = AtcProcessType;
              }
            }
            else
            {
              // Detect file type
              ProcessType = AppSettings.Instance.DetectFileType();
            }

            if (AppSettings.Instance.FileList.Count() > 0)
            {
              //----------------------------------------------------------------------
              // Encryption
              if (ProcessType == PROCESS_TYPE_NONE || ProcessType == PROCESS_TYPE_ATC || ProcessType == PROCESS_TYPE_ATC_EXE)
              {
            panelStartPage.Visible = false;
            panelEncrypt.Visible = true;         // Encrypt
            panelEncryptConfirm.Visible = false;
            panelDecrypt.Visible = false;
            panelProgressState.Visible = false;

            /*
            if (ProcessType == FILE_TYPE_ATC_EXE) // Executable
            {
              pictureBoxEncryption.Image = pictureBoxExeOn.Image;
            }
            else
            {
              pictureBoxEncryption.Image = pictureBoxAtcOn.Image;
            }
            */

            this.Activate();              // MainForm is Activated
            textBoxPassword.Focus();      // Text box is focused
              }
              //----------------------------------------------------------------------
              // Decryption
              else if (ProcessType == PROCESS_TYPE_DECRYPTION)
              {
            panelStartPage.Visible = false;
            panelEncrypt.Visible = false;
            panelEncryptConfirm.Visible = false;
            panelDecrypt.Visible = true;
            panelProgressState.Visible = false;
            textBoxDecryptPassword.Focus();     // Text box is focused
            this.Activate();                    // MainForm is Activated
              }
              //----------------------------------------------------------------------
              // Password ZIP
              else if (ProcessType == FILE_TYPE_PASSWORD_ZIP)
              {
            panelStartPage.Visible = false;
            panelEncrypt.Visible = false;
            panelEncryptConfirm.Visible = false;
            panelDecrypt.Visible = true;            // Decrypt
            panelProgressState.Visible = false;

            pictureBoxEncryption.Image = pictureBoxZipOn.Image;

            this.Activate();                     // MainForm is Activated
            textBoxPassword.Focus();             // Text box is focused
              }
              //----------------------------------------------------------------------
              else
              {
            panelStartPage.Visible = true;       // Main Window
            panelEncrypt.Visible = false;
            panelEncryptConfirm.Visible = false;
            panelDecrypt.Visible = false;
            panelProgressState.Visible = false;
              }

              this.BackColor = Color.White;
            }

              }

              //----------------------------------------------------------------------
              // コマンドラインオプションからのパスワードが優先される
              // The password of command line option is still more priority.
              if (AppSettings.Instance.EncryptPasswordStringFromCommandLine != null ||
              AppSettings.Instance.DecryptPasswordStringFromCommandLine != null)
              {
            if (panelEncrypt.Visible == true)
            {
              // Password
              textBoxPassword.Text = AppSettings.Instance.EncryptPasswordStringFromCommandLine;
              textBoxRePassword.Text = AppSettings.Instance.EncryptPasswordStringFromCommandLine;

              // コマンドラインオプションからのパスワード:
              // The password of command line option:
              labelPassword.Text = Resources.labelPasswordOfCommandLineOption;
              labelInputPasswordAgain.Text = Resources.labelPasswordOfCommandLineOption;

              panelEncrypt.Visible = false;
              panelEncryptConfirm.Visible = true;

              buttonEncryptStart.Focus();

              // 確認せず即座に実行
              // Run immediately without confirming
              if (AppSettings.Instance.fMemPasswordExe == true)
              {
            buttonEncryptStart.PerformClick();
              }
            }
            else if (panelDecrypt.Visible == true)
            {
              // Password
              textBoxDecryptPassword.Text = AppSettings.Instance.DecryptPasswordStringFromCommandLine;

              // コマンドラインオプションからのパスワード:
              // The password of command line option:
              labelDecryptionPassword.Text = Resources.labelPasswordOfCommandLineOption;

              buttonDecryptStart.Focus();

              // 確認せず即座に実行
              // Run immediately without confirming
              if (AppSettings.Instance.fMemPasswordExe == true)
              {
            buttonDecryptStart.PerformClick();
              }
            }
              }
              //-----------------------------------
              // 記憶パスワード(パスワードファイルより優先される)
              // Memorized password is priority than the saved password file
              else if (AppSettings.Instance.fMyEncryptPasswordKeep == true ||
                AppSettings.Instance.fMyDecryptPasswordKeep == true)
              {

            if (panelEncrypt.Visible == true)
            {
              // Password
              textBoxPassword.Text = AppSettings.Instance.MyEncryptPasswordString;
              textBoxRePassword.Text = AppSettings.Instance.MyEncryptPasswordString;

              // 記憶パスワード:
              // The memorized password:
              labelPassword.Text = Resources.labelPasswordMemorized;
              labelInputPasswordAgain.Text = Resources.labelPasswordMemorized;

              panelEncrypt.Visible = false;
              panelEncryptConfirm.Visible = true;

              buttonEncryptStart.Focus();

              // 確認せず即座に実行
              // Run immediately without confirming
              if (AppSettings.Instance.fMyEncryptPasswordKeep == true && AppSettings.Instance.fMemPasswordExe == true)
              {
            buttonEncryptStart.PerformClick();
              }
            }
            else if (panelDecrypt.Visible == true)
            {
              // Password
              textBoxDecryptPassword.Text = AppSettings.Instance.MyDecryptPasswordString;

              // 記憶パスワード:
              // The memorized password:
              labelDecryptionPassword.Text = Resources.labelPasswordMemorized;

              buttonDecryptStart.Focus();

              // 確認せず即座に実行
              // Run immediately without confirming
              if (AppSettings.Instance.fMyDecryptPasswordKeep && AppSettings.Instance.fMemPasswordExe == true)
              {
            buttonDecryptStart.PerformClick();
              }
            }

              }
              //-----------------------------------
              // パスワードファイル
              // Password file
              else
              {
            //----------------------------------------------------------------------
            // Decryption
            if (AppSettings.Instance.fCheckPassFileDecrypt == true && panelDecrypt.Visible == true)
            {
              if (File.Exists(AppSettings.Instance.PassFilePath) == true)
              {
            AppSettings.Instance.MyDecryptPasswordBinary = GetPasswordFileHash3(AppSettings.Instance.PassFilePathDecrypt);
            textBoxDecryptPassword.Text = AppSettings.BytesToHexString(AppSettings.Instance.MyDecryptPasswordBinary);

            textBoxDecryptPassword.Enabled = false;
            textBoxDecryptPassword.BackColor = SystemColors.ButtonFace;

            // パスワードファイル:
            // The Password file:
            labelPassword.Text = Resources.labelPasswordFile;
            labelInputPasswordAgain.Text = Resources.labelPasswordFile;

            panelStartPage.Visible = false;
            panelEncrypt.Visible = false;
            panelEncryptConfirm.Visible = false;
            panelDecrypt.Visible = true;
            panelProgressState.Visible = false;

            buttonDecryptStart.Focus();

            if ( AppSettings.Instance.fPasswordFileExe == true)
            {
              buttonDecryptStart.PerformClick();
            }

              }
              else
              {
            if (AppSettings.Instance.fNoErrMsgOnPassFile == false)
            {
              // 注意
              // 動作設定で指定されたパスワードファイルが見つかりません。
              // [FilePath]
              //
              // Alert
              // Password is not found that specified in setting panel.
              // [FilePath]
              DialogResult ret = MessageBox.Show(
                new Form { TopMost = true },
                Resources.DialogMessagePasswordFileNotFound + Environment.NewLine + AppSettings.Instance.PassFilePathDecrypt,
              Resources.DialogTitleAlert, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return;
              }
            }
            //----------------------------------------------------------------------
            // Encryption
            else if (AppSettings.Instance.fCheckPassFile == true && panelEncrypt.Visible == true)
            {
              if (File.Exists(AppSettings.Instance.PassFilePath) == true)
              {
            AppSettings.Instance.MyDecryptPasswordBinary = GetPasswordFileHash3(AppSettings.Instance.PassFilePath);
            textBoxPassword.Text = AppSettings.BytesToHexString(AppSettings.Instance.MyDecryptPasswordBinary);
            textBoxRePassword.Text = textBoxPassword.Text;

            // パスワードファイル:
            // The Password file:
            labelPassword.Text = Resources.labelPasswordFile;
            labelInputPasswordAgain.Text = Resources.labelPasswordFile;

            textBoxPassword.Enabled = false;
            textBoxPassword.BackColor = SystemColors.ButtonFace;
            textBoxRePassword.Enabled = false;
            textBoxRePassword.BackColor = SystemColors.ButtonFace;

            panelStartPage.Visible = false;
            panelEncrypt.Visible = false;
            panelEncryptConfirm.Visible = true;
            panelDecrypt.Visible = false;
            panelProgressState.Visible = false;

            buttonEncryptStart.Focus();

            if (AppSettings.Instance.fPasswordFileExe == true)
            {
              buttonEncryptStart.PerformClick();
            }

              }
              else
              {
            if (AppSettings.Instance.fNoErrMsgOnPassFile == false)
            {
              // 注意
              // 動作設定で指定されたパスワードファイルが見つかりません。
              // [FilePath]
              //
              // Alert
              // Password is not found that specified in setting panel.
              // [FilePath]
              DialogResult ret = MessageBox.Show(
                new Form { TopMost = true },
                Resources.DialogMessagePasswordFileNotFound + Environment.NewLine + AppSettings.Instance.PassFilePath,
              Resources.DialogTitleAlert, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return;
              }
            }

              }
        }