Ejemplo n.º 1
0
        private void OnClickKeyFileCreate(object sender, EventArgs e)
        {
            SaveFileDialogEx sfd = UIUtil.CreateSaveFileDialog(KPRes.KeyFileCreate,
                                                               UrlUtil.StripExtension(UrlUtil.GetFileName(m_ioInfo.Path)) + "." +
                                                               AppDefs.FileExtension.KeyFile, UIUtil.CreateFileTypeFilter("key",
                                                                                                                          KPRes.KeyFiles, true), 1, "key", AppDefs.FileDialogContext.KeyFile);

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                EntropyForm dlg = new EntropyForm();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    byte[] pbAdditionalEntropy = dlg.GeneratedEntropy;

                    try
                    {
                        KcpKeyFile.Create(sfd.FileName, pbAdditionalEntropy);

                        string str = sfd.FileName;
                        m_cmbKeyFile.Items.Add(str);
                        m_cmbKeyFile.SelectedIndex = m_cmbKeyFile.Items.Count - 1;
                    }
                    catch (Exception exKC)
                    {
                        MessageService.ShowWarning(exKC);
                    }
                }
                UIUtil.DestroyForm(dlg);
            }

            EnableUserControls();
        }
Ejemplo n.º 2
0
        private string CreateKeyFile()
        {
            byte[] pbEntropy = null;
            if (m_cbNewEntropy.Checked)
            {
                EntropyForm dlg = new EntropyForm();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    pbEntropy = dlg.GeneratedEntropy;
                }
                UIUtil.DestroyForm(dlg);

                if (pbEntropy == null)
                {
                    return(null);
                }
            }

            string strFilePath = GetKeyFilePath();

            if (string.IsNullOrEmpty(strFilePath))
            {
                return(null);
            }

            KcpKeyFile.Create(strFilePath, pbEntropy, m_vNewFormat[
                                  m_cmbNewFormat.SelectedIndex].Version);
            return(strFilePath);
        }
Ejemplo n.º 3
0
		public static byte[] CollectEntropyIfEnabled(PwProfile pp)
		{
			if(pp.CollectUserEntropy == false) return null;

			EntropyForm ef = new EntropyForm();
			if(ef.ShowDialog() == DialogResult.OK)
				return ef.GeneratedEntropy;

			return null;
		}
Ejemplo n.º 4
0
        public static byte[] CollectEntropyIfEnabled(PwProfile pp)
        {
            if (pp.CollectUserEntropy == false)
            {
                return(null);
            }

            EntropyForm ef = new EntropyForm();

            if (ef.ShowDialog() == DialogResult.OK)
            {
                return(ef.GeneratedEntropy);
            }

            return(null);
        }
Ejemplo n.º 5
0
        private void OnClickKeyFileCreate(object sender, EventArgs e)
        {
            SaveFileDialogEx sfd = UIUtil.CreateSaveFileDialog(KPRes.KeyFileCreate,
                UrlUtil.StripExtension(UrlUtil.GetFileName(m_ioInfo.Path)) + "." +
                AppDefs.FileExtension.KeyFile, UIUtil.CreateFileTypeFilter("key",
                KPRes.KeyFiles, true), 1, "key", AppDefs.FileDialogContext.KeyFile);

            if(sfd.ShowDialog() == DialogResult.OK)
            {
                EntropyForm dlg = new EntropyForm();
                if(dlg.ShowDialog() == DialogResult.OK)
                {
                    byte[] pbAdditionalEntropy = dlg.GeneratedEntropy;

                    try
                    {
                        KcpKeyFile.Create(sfd.FileName, pbAdditionalEntropy);

                        string str = sfd.FileName;
                        m_cmbKeyFile.Items.Add(str);
                        m_cmbKeyFile.SelectedIndex = m_cmbKeyFile.Items.Count - 1;
                    }
                    catch(Exception exKC)
                    {
                        MessageService.ShowWarning(exKC);
                    }
                }
                UIUtil.DestroyForm(dlg);
            }

            EnableUserControls();
        }