コード例 #1
0
ファイル: KeyCreationForm.cs プロジェクト: fsdsabel/keepass
        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();
        }
コード例 #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);
        }
コード例 #3
0
ファイル: EntropyForm.cs プロジェクト: ComradeP/KeePass-2.x
		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;
		}
コード例 #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);
        }
コード例 #5
0
ファイル: KeyCreationForm.cs プロジェクト: ashwingj/keepass2
        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();
        }