/// <summary>
        /// 根据微信小程序平台提供的解密算法解密数据,推荐直接使用此方法
        /// </summary>
        /// <param name="loginInfo">登陆信息</param>
        /// <returns>用户信息</returns>
        public WechatUserInfo Decrypt(WechatLoginInfo loginInfo)
        {
            if (String.IsNullOrEmpty(loginInfo?.code))
            {
                return(null);
            }
            OpenIdAndSessionKey oiask = DecodeOpenIdAndSessionKey(loginInfo);

            LogHelper.Logger.Error(JsonConvert.SerializeObject(oiask));
            if (oiask == null)
            {
                return(null);
            }

            var userinfo = new WechatUserInfo();

            if (!VaildateUserInfo(loginInfo, oiask))
            {
                if (oiask.openid.IsNullOrWhiteSpace())
                {
                    return(null);
                }
                userinfo.openId = oiask.openid;
                return(userinfo);
            }
            WechatUserInfo userInfo = Decrypt(loginInfo.encryptedData, loginInfo.iv, oiask.session_key);

            return(userInfo);
        }
 /// <summary>
 /// 根据微信小程序平台提供的签名验证算法验证用户发来的数据是否有效
 /// </summary>
 /// <param name="loginInfo">登陆信息</param>
 /// <param name="idAndKey">包含OpenId和SessionKey的类</param>
 /// <returns>True:资料有效,False:资料无效</returns>
 public bool VaildateUserInfo(WechatLoginInfo loginInfo, OpenIdAndSessionKey idAndKey)
 {
     return(VaildateUserInfo(loginInfo, idAndKey.session_key));
 }
        /// <summary>
        /// 反序列化包含OpenId和SessionKey的Json数据包
        /// </summary>
        /// <returns>包含OpenId和SessionKey的类</returns>
        public OpenIdAndSessionKey DecodeOpenIdAndSessionKey(WechatLoginInfo loginInfo)
        {
            OpenIdAndSessionKey oiask = JsonConvert.DeserializeObject <OpenIdAndSessionKey>(GetOpenIdAndSessionKeyString(loginInfo.code));

            return(oiask);
        }