private void PasswordGeneratorCommand(RowObject rowObject)
        {
            var passwordGenerator = new PwGeneratorForm();

            PwProfile profile = null;

            if (!rowObject.Value.IsEmpty)
            {
                profile = KeePassLib.Cryptography.PasswordGenerator.PwProfile.DeriveFromPassword(rowObject.Value);
            }
            passwordGenerator.InitEx(profile, true, false);

            if (passwordGenerator.ShowDialog() == DialogResult.OK)
            {
                // Logic copied from PwEntryForm.OnPwGenOpen (PwEntryForm.cs)
                var             entropy = EntropyForm.CollectEntropyIfEnabled(passwordGenerator.SelectedProfile);
                ProtectedString newPassword;
                PwGenerator.Generate(out newPassword, passwordGenerator.SelectedProfile, entropy, KeePass.Program.PwGeneratorPool);

                SetFieldValue(rowObject, newPassword);

                RefreshObject(rowObject);
            }

            UIUtil.DestroyForm(passwordGenerator);
        }
Пример #2
0
        private void OnPWGenOpen(object sender, EventArgs e)
        {
            ProtectedString ps  = m_icgNewPassword.GetPasswordEx();
            PwProfile       opt = PwProfile.DeriveFromPassword(ps);

            PwGeneratorForm pgf = new PwGeneratorForm();

            pgf.InitEx((!ps.IsEmpty ? opt : null), true, false);

            if (pgf.ShowDialog() == DialogResult.OK)
            {
                CreateNewPassword(pgf.SelectedProfile);
                m_Profile = pgf.SelectedProfile;
            }
            UpdateProfilesContextMenu();
            UIUtil.DestroyForm(pgf);
        }
Пример #3
0
        private void OnPwGenOpen(object sender, EventArgs e)
        {
            PwGeneratorForm pgf             = new PwGeneratorForm();
            ProtectedString ps              = current_password_field.TextEx;
            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_confirm_field.TextEx = current_password_field.TextEx = psNew;
            }
        }
Пример #4
0
        private void OnGenOpen(object sender, EventArgs e)
        {
            PwProfile       prf = null;
            ProtectedString ps  = (GetPassword() ?? ProtectedString.Empty);

            if (!ps.IsEmpty && !IsMultipleValues(ps))
            {
                prf = PwProfile.DeriveFromPassword(ps);
            }

            PwGeneratorForm pgf = new PwGeneratorForm();

            pgf.InitEx(prf, true, false);

            if (pgf.ShowDialog() == DialogResult.OK)
            {
                GenerateAndSetPassword(pgf.SelectedProfile);
            }

            UIUtil.DestroyForm(pgf);
        }