示例#1
0
        // Token: 0x060001CC RID: 460 RVA: 0x0000798C File Offset: 0x00005B8C
        private string ApiQuery(string apiName, IDictionary <string, string> req, string Method = "POST")
        {
            string text = ((int)Math.Round(DateTime.Now.Subtract(new DateTime(2018, 1, 1)).TotalSeconds * 100.0)).ToString();
            string result;

            using (HttpRequest httpRequest = new HttpRequest())
            {
                string text2 = LivecoinAPI.http_build_query(this.ToQueryString(req));
                string text3 = LivecoinAPI.HashHMAC(this._privateKey, text2).ToUpper();
                httpRequest.IgnoreProtocolErrors = true;
                httpRequest.AddHeader("Sign", text3);
                httpRequest.AddHeader("Api-Key", this._publicKey);
                NameValueCollection nameValueCollection = req.ToNameValueCollection <string, string>();
                string text4 = string.Empty;
                bool   flag  = Method == "POST";
                if (flag)
                {
                    text4 = httpRequest.Post(this._baseAdress + apiName, text2, "application/x-www-form-urlencoded").ToString();
                }
                else
                {
                    bool flag2 = !string.IsNullOrWhiteSpace(text2);
                    if (flag2)
                    {
                        text4 = httpRequest.Get(this._baseAdress + apiName + "?" + text2, null).ToString();
                    }
                    else
                    {
                        text4 = httpRequest.Get(this._baseAdress + apiName, null).ToString();
                    }
                }
                result = text4;
            }
            return(result);
        }
示例#2
0
        // Token: 0x060001C7 RID: 455 RVA: 0x000076F4 File Offset: 0x000058F4
        private static string HashHMAC(string key, string message)
        {
            UTF8Encoding utf8Encoding = new UTF8Encoding();

            byte[]     bytes   = utf8Encoding.GetBytes(key);
            HMACSHA256 hmacsha = new HMACSHA256(bytes);

            byte[] bytes2 = utf8Encoding.GetBytes(message);
            byte[] ba     = hmacsha.ComputeHash(bytes2);
            return(LivecoinAPI.ByteArrayToString(ba));
        }