Esempio n. 1
0
        protected override object[] HttpCallAuth(HttpClient _http, string _method, ref string _url, object[] _keyValues)
        {
            Dictionary <string, string> _list = new Dictionary <string, string>();

            for (int i = 0; i < _keyValues.Length - 1; i += 2)
            {
                _list.Add(_keyValues[i].ToString(), _keyValues[i + 1].ToString());
            }
            KeyValuePair <string, string>[] _sorted = _list.ToArray().OrderBy(c => c.Key).ToArray();

            string _ts   = (DateTimePlus.DateTime2JSTime(DateTime.UtcNow) * 1000).ToString();
            string _sign = _method + this.HttpUrl + _url + _ts;

            for (int i = 0; i < _sorted.Length; i++)
            {
                _sign += i == 0 ? "" : "&";
                _sign += _sorted[i].Key + "=" + _sorted[i].Value;
            }
            _sign = Base64.Encode(Encoding.UTF8.GetBytes(_sign));
            _sign = SHA.EncodeHMACSHA1ToBase64(_sign, base.Secret);

            _http.Headers.Add("FC-ACCESS-KEY", base.Key);
            _http.Headers.Add("FC-ACCESS-SIGNATURE", _sign);
            _http.Headers.Add("FC-ACCESS-TIMESTAMP", _ts);

            return(_keyValues);
        }