private void _uploadUntrustSignatureListView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            if (_uploadLinkListView.SelectedIndex == -1)
            {
                _uploadUntrustSignatureListViewDeleteMenuItem.IsEnabled = false;
                _uploadUntrustSignatureListViewCutMenuItem.IsEnabled    = false;
                _uploadUntrustSignatureListViewCopyMenuItem.IsEnabled   = false;
                _uploadUntrustSignatureListViewPasteMenuItem.IsEnabled  = false;
            }
            else
            {
                var selectItems = _uploadUntrustSignatureListView.SelectedItems;

                _uploadUntrustSignatureListViewDeleteMenuItem.IsEnabled = (selectItems != null && selectItems.Count > 0);
                _uploadUntrustSignatureListViewCutMenuItem.IsEnabled    = (selectItems != null && selectItems.Count > 0);
                _uploadUntrustSignatureListViewCopyMenuItem.IsEnabled   = (selectItems != null && selectItems.Count > 0);

                {
                    bool flag = false;

                    if (Clipboard.ContainsText())
                    {
                        var line = Clipboard.GetText().Split('\r', '\n');
                        flag = Signature.Check(line[0]);
                    }

                    _uploadUntrustSignatureListViewPasteMenuItem.IsEnabled = flag;
                }
            }
        }
Beispiel #2
0
        public void Test_Sigunature()
        {
            foreach (var a in new DigitalSignatureAlgorithm[] { DigitalSignatureAlgorithm.Rsa2048_Sha256, DigitalSignatureAlgorithm.EcDsaP521_Sha256 })
            {
                var signature = Signature.GetSignature(new DigitalSignature("123", a));

                Assert.IsTrue(Signature.Check(signature));
                Assert.AreEqual(Signature.GetNickname(signature), "123");
                Assert.IsTrue(Signature.GetHash(signature).Length == 32);
            }

            foreach (var a in new DigitalSignatureAlgorithm[] { DigitalSignatureAlgorithm.Rsa2048_Sha256, DigitalSignatureAlgorithm.EcDsaP521_Sha256 })
            {
                string signature;

                using (MemoryStream stream = new MemoryStream())
                {
                    stream.Write(new byte[1024], 0, 1024);
                    signature = Signature.GetSignature(DigitalSignature.CreateCertificate(new DigitalSignature("123", a), stream));
                }

                Assert.IsTrue(Signature.Check(signature));
                Assert.AreEqual(Signature.GetNickname(signature), "123");
                Assert.IsTrue(Signature.GetHash(signature).Length == 32);
            }
        }
Beispiel #3
0
        //
        // GET: /Wechat/

        /// <summary>
        /// 此Get请求验证服务器地址的有效性
        ///
        /// 注释:
        /// GET请求携带四个参数:
        /// 参数	        描述
        /// signature	    微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
        /// timestamp	    时间戳
        /// nonce	        随机数
        /// echostr	        随机字符串
        /// </summary>
        /// <param name="signature"></param>
        /// <param name="timestamp"></param>
        /// <param name="nonce"></param>
        /// <param name="echostr"></param>
        /// <returns></returns>
        public string Index(string signature, string timestamp, string nonce, string echostr)
        {
            if (Signature.Check(signature, timestamp, nonce, "liblog"))
            {
                return(echostr);
            }

            return("接入失败");
        }
        public ActionResult Get(string signature, string timestamp, string nonce, string echostr)
        {
            var token = ConfigurationManager.AppSettings["weixin.token"];

            if (Signature.Check(token, timestamp, nonce, signature))
            {
                return(Content(echostr));
            }

            return(View("Get"));
        }
Beispiel #5
0
        public IActionResult OnGet(string signature, string timestamp, string nonce, string echostr)
        {
            if (!string.IsNullOrEmpty(signature))
            {
                if (Signature.Check(_settings.Token, timestamp, nonce, signature))
                {
                    return(Content(echostr));
                }
            }

            return(Page());
        }
        private void _downloadSignatureListViewPasteMenuItem_Click(object sender, RoutedEventArgs e)
        {
            foreach (var signature in Clipboard.GetText().Split('\r', '\n'))
            {
                if (!Signature.Check(signature))
                {
                    continue;
                }

                _downloadSignatureCollection.Add(signature);
            }
        }
        private void _downloadSignatureListView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            var selectItems = _downloadSignatureListView.SelectedItems;

            _downloadSignatureListViewDeleteMenuItem.IsEnabled = (selectItems == null) ? false : (selectItems.Count > 0);
            _downloadSignatureListViewCutMenuItem.IsEnabled    = (selectItems == null) ? false : (selectItems.Count > 0);
            _downloadSignatureListViewCopyMenuItem.IsEnabled   = (selectItems == null) ? false : (selectItems.Count > 0);

            {
                bool flag = false;

                if (Clipboard.ContainsText())
                {
                    var line = Clipboard.GetText().Split('\r', '\n');
                    flag = Signature.Check(line[0]);
                }

                _downloadSignatureListViewPasteMenuItem.IsEnabled = flag;
            }
        }
Beispiel #8
0
        public void SetSearchSignatures(IEnumerable <string> signatures)
        {
            lock (this.ThisLock)
            {
                lock (_settings.Signatures.ThisLock)
                {
                    _settings.Signatures.Clear();

                    foreach (var signature in signatures)
                    {
                        if (signature == null || !Signature.Check(signature))
                        {
                            continue;
                        }

                        _settings.Signatures.Add(signature);
                    }
                }
            }
        }
Beispiel #9
0
        private void _downloadLinkListViewPasteMenuItem_Click(object sender, RoutedEventArgs e)
        {
            foreach (var signature in Clipboard.GetText().Split('\r', '\n'))
            {
                if (!Signature.Check(signature))
                {
                    continue;
                }

                var item = new LinkViewModel()
                {
                    Signature = signature,
                };

                if (_downloadCollection.Any(n => n.Signature == signature))
                {
                    continue;
                }
                _downloadCollection.Add(item);
            }
        }
        private void _uploadUntrustSignatureListViewPasteMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var viewModel = _uploadLinkListView.SelectedItem as LinkViewModel;

            if (viewModel == null)
            {
                return;
            }

            foreach (var signature in Clipboard.GetText().Split('\r', '\n'))
            {
                if (!Signature.Check(signature))
                {
                    continue;
                }

                if (viewModel.DeleteSignatures.Contains(signature))
                {
                    continue;
                }
                viewModel.DeleteSignatures.Add(signature);
            }
        }