public void SetPassword(byte[] pbUtf8, bool bSetRepeatPw) { if (pbUtf8 == null) { Debug.Assert(false); return; } ++m_uBlockUIUpdate; m_secPassword.SetPassword(pbUtf8); if (bSetRepeatPw && !this.AutoRepeat) { m_secRepeat.SetPassword(pbUtf8); } --m_uBlockUIUpdate; UpdateUI(); }
private void UpdateUI() { if ((m_uBlockUIUpdate > 0) || m_bInitializing) { return; } ++m_uBlockUIUpdate; ulong uFlags = 0; if (m_fParent is KeyCreationForm) { uFlags = Program.Config.UI.KeyCreationFlags; } byte[] pbUtf8 = m_secPassword.ToUtf8(); m_tbPassword.Enabled = m_bEnabled; m_cbHide.Enabled = (m_bEnabled && ((uFlags & (ulong)AceKeyUIFlags.DisableHidePassword) == 0)); if ((uFlags & (ulong)AceKeyUIFlags.CheckHidePassword) != 0) { m_bPrgmCheck = true; m_cbHide.Checked = true; m_bPrgmCheck = false; } if ((uFlags & (ulong)AceKeyUIFlags.UncheckHidePassword) != 0) { m_bPrgmCheck = true; m_cbHide.Checked = false; m_bPrgmCheck = false; } bool bAutoRepeat = this.AutoRepeat; if (bAutoRepeat && (m_secRepeat.TextLength > 0)) { m_secRepeat.SetPassword(new byte[0]); } byte[] pbRepeat = m_secRepeat.ToUtf8(); if (!MemUtil.ArraysEqual(pbUtf8, pbRepeat) && !bAutoRepeat) { m_tbRepeat.BackColor = AppDefs.ColorEditError; } else { m_tbRepeat.ResetBackColor(); } bool bRepeatEnable = (m_bEnabled && !bAutoRepeat); m_lblRepeat.Enabled = bRepeatEnable; m_tbRepeat.Enabled = bRepeatEnable; m_lblQualityPrompt.Enabled = m_bEnabled; m_pbQuality.Enabled = m_bEnabled; m_lblQualityBits.Enabled = m_bEnabled; uint uBits = QualityEstimation.EstimatePasswordBits(pbUtf8); m_lblQualityBits.Text = uBits.ToString() + " " + KPRes.Bits; int iPos = (int)((100 * uBits) / (256 / 2)); if (iPos < 0) { iPos = 0; } else if (iPos > 100) { iPos = 100; } m_pbQuality.Value = iPos; MemUtil.ZeroByteArray(pbUtf8); MemUtil.ZeroByteArray(pbRepeat); --m_uBlockUIUpdate; }
private void UpdateUI() { if ((m_uBlockUIUpdate > 0) || m_bInitializing) { return; } ++m_uBlockUIUpdate; ulong uFlags = 0; if (m_fParent is KeyCreationForm) { uFlags = Program.Config.UI.KeyCreationFlags; } byte[] pbUtf8 = m_secPassword.ToUtf8(); string str = StrUtil.Utf8.GetString(pbUtf8); #if DEBUG byte[] pbTest = StrUtil.Utf8.GetBytes(str); Debug.Assert(MemUtil.ArraysEqual(pbUtf8, pbTest)); #endif m_tbPassword.Enabled = m_bEnabled; m_cbHide.Enabled = (m_bEnabled && ((uFlags & (ulong)AceKeyUIFlags.DisableHidePassword) == 0)); if ((uFlags & (ulong)AceKeyUIFlags.CheckHidePassword) != 0) { ++m_uPrgmCheck; m_cbHide.Checked = true; --m_uPrgmCheck; } if ((uFlags & (ulong)AceKeyUIFlags.UncheckHidePassword) != 0) { ++m_uPrgmCheck; m_cbHide.Checked = false; --m_uPrgmCheck; } bool bAutoRepeat = this.AutoRepeat; if (bAutoRepeat && (m_secRepeat.TextLength > 0)) { m_secRepeat.SetPassword(MemUtil.EmptyByteArray); } byte[] pbRepeat = m_secRepeat.ToUtf8(); if (!MemUtil.ArraysEqual(pbUtf8, pbRepeat) && !bAutoRepeat) { m_tbRepeat.BackColor = AppDefs.ColorEditError; } else { m_tbRepeat.ResetBackColor(); } bool bRepeatEnable = (m_bEnabled && !bAutoRepeat); m_lblRepeat.Enabled = bRepeatEnable; m_tbRepeat.Enabled = bRepeatEnable; bool bQuality = m_bEnabled; if (m_bSprVar && bQuality) { if (SprEngine.MightChange(str)) // Perf. opt. { // {S:...} and {REF:...} may reference the entry that // is currently being edited and SprEngine will not see // the current data entered in the dialog; thus we // disable quality estimation for all strings containing // one of these placeholders if ((str.IndexOf(@"{S:", StrUtil.CaseIgnoreCmp) >= 0) || (str.IndexOf(@"{REF:", StrUtil.CaseIgnoreCmp) >= 0)) { bQuality = false; } else { SprContext ctx = new SprContext(m_ctxEntry, m_ctxDatabase, SprCompileFlags.NonActive, false, false); string strCmp = SprEngine.Compile(str, ctx); if (strCmp != str) { bQuality = false; } } } #if DEBUG else { SprContext ctx = new SprContext(m_ctxEntry, m_ctxDatabase, SprCompileFlags.NonActive, false, false); string strCmp = SprEngine.Compile(str, ctx); Debug.Assert(strCmp == str); } #endif } m_lblQualityPrompt.Enabled = bQuality; m_pbQuality.Enabled = bQuality; m_lblQualityInfo.Enabled = bQuality; if ((Program.Config.UI.UIFlags & (ulong)AceUIFlags.HidePwQuality) != 0) { m_lblQualityPrompt.Visible = false; m_pbQuality.Visible = false; m_lblQualityInfo.Visible = false; } else if (bQuality || !m_bSprVar) { UpdateQualityInfo(str); } else { UqiShowQuality(0, 0); } // MemUtil.ZeroByteArray(pbUtf8); // MemUtil.ZeroByteArray(pbRepeat); --m_uBlockUIUpdate; }
private void UpdateUI() { if ((m_uBlockUIUpdate > 0) || m_bInitializing) { return; } ++m_uBlockUIUpdate; ulong uFlags = 0; if (m_fParent is KeyCreationForm) { uFlags = Program.Config.UI.KeyCreationFlags; } byte[] pbUtf8 = m_secPassword.ToUtf8(); m_tbPassword.Enabled = m_bEnabled; m_cbHide.Enabled = (m_bEnabled && ((uFlags & (ulong)AceKeyUIFlags.DisableHidePassword) == 0)); if ((uFlags & (ulong)AceKeyUIFlags.CheckHidePassword) != 0) { ++m_uPrgmCheck; m_cbHide.Checked = true; --m_uPrgmCheck; } if ((uFlags & (ulong)AceKeyUIFlags.UncheckHidePassword) != 0) { ++m_uPrgmCheck; m_cbHide.Checked = false; --m_uPrgmCheck; } bool bAutoRepeat = this.AutoRepeat; if (bAutoRepeat && (m_secRepeat.TextLength > 0)) { m_secRepeat.SetPassword(new byte[0]); } byte[] pbRepeat = m_secRepeat.ToUtf8(); if (!MemUtil.ArraysEqual(pbUtf8, pbRepeat) && !bAutoRepeat) { m_tbRepeat.BackColor = AppDefs.ColorEditError; } else { m_tbRepeat.ResetBackColor(); } bool bRepeatEnable = (m_bEnabled && !bAutoRepeat); m_lblRepeat.Enabled = bRepeatEnable; m_tbRepeat.Enabled = bRepeatEnable; m_lblQualityPrompt.Enabled = m_bEnabled; m_pbQuality.Enabled = m_bEnabled; m_lblQualityBits.Enabled = m_bEnabled; UpdateQualityInfo(pbUtf8); // MemUtil.ZeroByteArray(pbUtf8); // MemUtil.ZeroByteArray(pbRepeat); --m_uBlockUIUpdate; }