private void OnToolsPwGenerator(object sender, EventArgs e) { PwDatabase pwDb = m_docMgr.ActiveDatabase; PwGeneratorForm pgf = new PwGeneratorForm(); pgf.InitEx(null, pwDb.IsOpen, IsTrayed()); if(pgf.ShowDialog() == DialogResult.OK) { if(pwDb.IsOpen) { PwGroup pg = GetSelectedGroup(); if(pg == null) pg = pwDb.RootGroup; PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); byte[] pbAdditionalEntropy = EntropyForm.CollectEntropyIfEnabled( pgf.SelectedProfile); ProtectedString psNew = new ProtectedString(pwDb.MemoryProtection.ProtectPassword); PwGenerator.Generate(psNew, pgf.SelectedProfile, pbAdditionalEntropy, Program.PwGeneratorPool); pe.Strings.Set(PwDefs.PasswordField, psNew); UpdateUI(false, null, false, null, true, null, true); if(m_lvEntries.Items.Count > 0) // Select new entry { m_lvEntries.EnsureVisible(m_lvEntries.Items.Count - 1); for(int i = 0; i < (m_lvEntries.Items.Count - 1); ++i) m_lvEntries.Items[i].Selected = false; // Deselect m_lvEntries.Items[m_lvEntries.Items.Count - 1].Selected = true; } } } UIUtil.DestroyForm(pgf); }
private void OnToolsGeneratePasswordList(object sender, EventArgs e) { PwDatabase pwDb = m_docMgr.ActiveDatabase; if(!pwDb.IsOpen) return; PwGeneratorForm pgf = new PwGeneratorForm(); pgf.InitEx(null, true, IsTrayed()); if(pgf.ShowDialog() == DialogResult.OK) { PwGroup pg = GetSelectedGroup(); if(pg == null) pg = pwDb.RootGroup; SingleLineEditForm dlgCount = new SingleLineEditForm(); dlgCount.InitEx(KPRes.GenerateCount, KPRes.GenerateCountDesc, KPRes.GenerateCountLongDesc, Properties.Resources.B48x48_KGPG_Gen, string.Empty, null); if(dlgCount.ShowDialog() == DialogResult.OK) { uint uCount; if(!uint.TryParse(dlgCount.ResultString, out uCount)) uCount = 1; byte[] pbAdditionalEntropy = EntropyForm.CollectEntropyIfEnabled( pgf.SelectedProfile); for(uint i = 0; i < uCount; ++i) { PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); ProtectedString psNew = new ProtectedString(pwDb.MemoryProtection.ProtectPassword); PwGenerator.Generate(psNew, pgf.SelectedProfile, pbAdditionalEntropy, Program.PwGeneratorPool); pe.Strings.Set(PwDefs.PasswordField, psNew); } UpdateUI(false, null, false, null, true, null, true); } UIUtil.DestroyForm(dlgCount); } UIUtil.DestroyForm(pgf); }
private void OnToolsPwGenerator(object sender, EventArgs e) { PwDatabase pwDb = m_docMgr.ActiveDatabase; PwGeneratorForm pgf = new PwGeneratorForm(); pgf.InitEx(null, pwDb.IsOpen, IsTrayed()); if(pgf.ShowDialog() == DialogResult.OK) { if(pwDb.IsOpen) { PwGroup pg = GetSelectedGroup(); if(pg == null) pg = pwDb.RootGroup; PwEntry pe = new PwEntry(true, true); pg.AddEntry(pe, true); byte[] pbAdditionalEntropy = EntropyForm.CollectEntropyIfEnabled( pgf.SelectedProfile); ProtectedString psNew; PwGenerator.Generate(out psNew, pgf.SelectedProfile, pbAdditionalEntropy, Program.PwGeneratorPool); psNew = psNew.WithProtection(pwDb.MemoryProtection.ProtectPassword); pe.Strings.Set(PwDefs.PasswordField, psNew); UpdateUI(false, null, false, null, true, null, true, m_lvEntries); PwObjectList<PwEntry> l = new PwObjectList<PwEntry>(); l.Add(pe); SelectEntries(l, true, true); EnsureVisibleSelected(false); } } UIUtil.DestroyForm(pgf); }
private void OnPwGenOpen(object sender, EventArgs e) { PwGeneratorForm pgf = new PwGeneratorForm(); ProtectedString ps = new ProtectedString(true, current_password_field.ToUtf8()); bool bAtLeastOneChar = (ps.Length > 0); PwProfile opt = PwProfile.DeriveFromPassword(ps); pgf.InitEx(bAtLeastOneChar ? opt : null, true, false); if (pgf.ShowDialog() == DialogResult.OK) { byte[] pbEntropy = EntropyForm.CollectEntropyIfEnabled(pgf.SelectedProfile); ProtectedString psNew; PwGenerator.Generate(out psNew, pgf.SelectedProfile, pbEntropy, Program.PwGeneratorPool); current_password_field.SetPassword(psNew.ReadUtf8()); current_password_confirm_field.SetPassword(psNew.ReadUtf8()); } }
private void OnPwGenOpen(object sender, EventArgs e) { byte[] pbCurPassword = m_icgPassword.GetPasswordUtf8(); bool bAtLeastOneChar = (pbCurPassword.Length > 0); ProtectedString ps = new ProtectedString(true, pbCurPassword); Array.Clear(pbCurPassword, 0, pbCurPassword.Length); PwProfile opt = PwProfile.DeriveFromPassword(ps); PwGeneratorForm pgf = new PwGeneratorForm(); pgf.InitEx((bAtLeastOneChar ? opt : null), true, false); if(pgf.ShowDialog() == DialogResult.OK) { byte[] pbEntropy = EntropyForm.CollectEntropyIfEnabled(pgf.SelectedProfile); ProtectedString psNew; PwGenerator.Generate(out psNew, pgf.SelectedProfile, pbEntropy, Program.PwGeneratorPool); byte[] pbNew = psNew.ReadUtf8(); m_icgPassword.SetPassword(pbNew, true); MemUtil.ZeroByteArray(pbNew); } UIUtil.DestroyForm(pgf); EnableControlsEx(); }
private void OnPwGenOpen(object sender, EventArgs e) { PwGeneratorForm pgf = new PwGeneratorForm(); byte[] pbCurPassword = m_secPassword.ToUtf8(); bool bAtLeastOneChar = (pbCurPassword.Length > 0); ProtectedString ps = new ProtectedString(true, pbCurPassword); Array.Clear(pbCurPassword, 0, pbCurPassword.Length); PwProfile opt = PwProfile.DeriveFromPassword(ps); pgf.InitEx(bAtLeastOneChar ? opt : null, true, false); if(pgf.ShowDialog() == DialogResult.OK) { byte[] pbEntropy = EntropyForm.CollectEntropyIfEnabled(pgf.SelectedProfile); ProtectedString psNew = new ProtectedString(true); PwGenerator.Generate(psNew, pgf.SelectedProfile, pbEntropy); byte[] pbNew = psNew.ReadUtf8(); m_secPassword.SetPassword(pbNew); m_secRepeat.SetPassword(pbNew); Array.Clear(pbNew, 0, pbNew.Length); m_bModifiedEntry = true; } EnableControlsEx(); }