Ejemplo n.º 1
0
        private string CalculateHMACSHA512Hex(IFormCollection request)
        {
            var requestContent = string.Join("&", request.OrderBy(x => x.Key).Select(p => $"{p.Key}={Uri.EscapeDataString(p.Value)}"));
            var key            = Encoding.UTF8.GetBytes(config.ApiSecret);

            using (var hm = new HMACSHA512(key))
            {
                var signed = hm.ComputeHash(Encoding.UTF8.GetBytes(requestContent));
                return(BitConverter.ToString(signed).Replace("-", string.Empty));
            }
        }
Ejemplo n.º 2
0
        public IActionResult Index(IFormCollection data)
        {
            var result = HandleRequest(data);
            var values = data
                         .OrderBy(x => x.Key, StringComparer.Ordinal)
                         .Select(x => $"  {x.Key}: {x.Value}\n");

            logger.LogWarning("{0} {1}\nQuery: {2}\nValue:\n{3}\n{4}",
                              HttpContext.Request.Method,
                              HttpContext.Request.GetUri(),
                              HttpContext.Request.QueryString,
                              string.Join("", values),
                              DumpResult(result));

            return(result);
        }
Ejemplo n.º 3
0
        public IActionResult Index([FromForm] IFormCollection data)
        {
            var result = HandleRequest(data);
            var values = data
                         .OrderBy(x => x.Key, StringComparer.Ordinal)
                         .Select(x => $"  {x.Key}: {x.Value}\n");

            //logger.LogWarning("{0} {1}\nQuery: {2}\nValue:\n{3}\n{4}",
            //                  HttpContext.Request.Method,
            //                  HttpContext.Request.GetDisplayUrl(),
            //                  HttpContext.Request.QueryString,
            //                  string.Join("", values),
            //                  DumpResult(result));

            requestLogger.Log(new LastmApiRequest(
                                  data["method"],
                                  data.ToDictionary(x => x.Key, x => x.Value),
                                  result));

            return(result);
        }