コード例 #1
0
ファイル: OrderService.cs プロジェクト: stupidHumanity/Order2
        public string Login(string name, string pwd)
        {
            name = Base64Cryptor.Encrypt(name);
            pwd  = Md5Cryptor.Encrypt(pwd);

            string         url_login = OrderService.host + ":8088/sysuser/login";
            HttpWebRequest request   = WebRequest.Create(url_login) as HttpWebRequest;

            request.Method      = "POST";
            request.ContentType = "application/json";
            string content = String.Format("{{\"username\":\"{0}\",\"loginPwd\":\"{1}\"}}", name, pwd);

            byte[] data = Encoding.UTF8.GetBytes(content);
            request.ContentLength = data.Length;
            request.Headers.Add("token", token);
            request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36";
            using (Stream reqStream = request.GetRequestStream())
            {
                reqStream.Write(data, 0, data.Length);
                reqStream.Close();
            }

            HttpWebResponse response  = (HttpWebResponse)request.GetResponse();
            string          retString = null;

            using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
            {
                retString = reader.ReadToEnd();
            }
            Stream myResponseStream = response.GetResponseStream();


            return(retString);
        }
コード例 #2
0
        public void Test_Decrypt()
        {
            var result = Base64Cryptor.Decrypt("SkNF");

            Output.WriteLine(result);
            Assert.Equal("JCE", result);
        }