C#接口校验appkey ,timestamp,sign

 /// 
        /// 验证必要信息
        /// 
        /// 
        /// 
        /// 
        /// 
        private JsonResult Verify(string appkey, long timestamp, string sign)
        {
            JsonResult result = null;
            long nowTimestamp = UtilsHelper.GetUnixTimestamp();
            var key = AppSetting.CommonAPIKey();
            if (appkey != key)
            {
                result = Json(RongboResult.Failed(-1, "appkey错误!"));
            }
            //有效期绝对值在30s以内
            if (!(nowTimestamp - timestamp <= 30 && timestamp - nowTimestamp >= -30))
            {
                result = Json(RongboResult.Failed(-1, "时间戳timestamp参数过期,有效期为30秒!"));
            }
            var appSecret = AppSetting.CommonAPISecret();
            var validationSign = MD5Helper.GetMD5_Utf8(appSecret + timestamp);
            if (validationSign != sign)
            {
                result = Json(RongboResult.Failed(-1, "sign错误!"));
            }
            return result;
        }

你可能感兴趣的:(前端,javascript,c#)