Пример #1
0
        public async Task <ServiceInvokeResult <bool> > AuthAppInfoAsync(int appId, long unixTime, string sign)
        {
            var key       = string.Format(CacheKeyConstant.AppConfig, appId);
            var appConfig = _caching.GetValue(key) as AppConfig;

            if (appConfig == null)
            {
                appConfig = await _appConfigRepository.QueryAsQueryable(a => a.AppId == appId).FirstAsync();
            }

            if (appConfig == null)
            {
                return(PrintInvokeResult(false, "不存在的应用ID"));
            }

            var signSource  = $"{appId}{appConfig.AppKey}{unixTime}";
            var correctSign = HashHelper.GetMd5(signSource);

            if (!correctSign.Equals(sign))
            {
                return(PrintInvokeResult(false, "签名错误"));
            }

            return(PrintInvokeResult(true, "验证通过"));
        }