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(); }
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); }
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; }
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); }
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(); }