private void HEncode(object sender, EventArgs e)
 {
     try
     {
         if (IsPasswordEnabled)
         {
             Impersonate(true);
         }
         Ciphertext.Value = Plaintext.Value.XEncrypt(ProtectionScope);
         var name = Setting.Value.Trim();
         if (name.StartsWith("<"))
         {
             var d = MXml.LoadText(name);
             name = d.X("key");
         }
         var pos = name.IndexOf(':');
         if (pos >= 0)
         {
             name = name.Substring(0, pos);
         }
         Setting.Value = "<add key=\"" + name + ":" + Username + "\" value=\"" + Ciphertext + "\"/>";
         CopyToClipboard();
     }
     catch (Exception ex)
     {
         ex.XHandle("encrypting plaintext");
     }
     finally
     {
         Impersonate(false);
     }
 }
        private void HDecode(object sender, EventArgs e)
        {
            try
            {
                if (IsPasswordEnabled)
                {
                    Impersonate(true);
                }
                var ct = Ciphertext.Value;
                if (ct.XIsBlank() && !Setting.Value.XIsBlank())
                {
                    try
                    {
                        var xml = MXml.LoadText(Setting);
                        ct = xml.X("value");
                    }
                    catch { throw MException.MessageException("Setting xml tag is not valid."); }

                    if (ct.XIsBlank())
                    {
                        throw MException.MessageException("Setting xml tag had no value attribute.");
                    }
                }
                Plaintext.Value = ct.XDecrypt();
            }
            catch (Exception ex)
            {
                ex = AnalyzeException(ex);
                ex.XHandle("decrypting");
            }
            finally
            {
                Impersonate(false);
            }
        }