Пример #1
0
        /// <summary>
        /// 微博密码加密
        /// </summary>
        /// <param name="data"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        private static string EncryptPassword(PreLoginResponseData data, string password)
        {
            RSAHelper rsa = new RSAHelper();

            rsa.RSASetPublic(data.pubkey, "10001");
            return(rsa.RSAEncrypt(data.servertime + "\t" + data.nonce + "\n" + password));
        }
Пример #2
0
 public static LoginResponseData Login(PreLoginResponseData data, string username, string password, string code, WebProxy proxy)
 {
     try
     {
         string userNameBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(HttpUtility.UrlEncode(username)));
         password = EncryptPassword(data, password);
         string     url  = "http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.4.18)&_=" + DateTime.Now.TimeStamp();
         PostHelper post = new PostHelper(url);
         post.Type    = PostTypeEnum.Post;
         post.Cookies = new CookieContainer();
         post.Cookies.SetCookies(new Uri("http://weibo.com"), data.cookies);
         post.Proxy     = proxy;
         post.PostItems = LoginData.Create(data, userNameBase64, password, code);
         string result       = post.Post();
         var    responseData = JsonConvert.DeserializeObject <LoginResponseData>(result);
         if (responseData != null)
         {
             responseData.cookies = PostHelper.GetAllCookies(post.Cookies);
             return(responseData);
         }
     }
     catch (Exception ex)
     { }
     return(null);
 }