/// <summary>
/// 验证必要信息
/// </summary>
/// <param name="appkey"></param>
/// <param name="timestamp"></param>
/// <param name="sign"></param>
/// <returns></returns>
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<bool>.Failed(-1, "appkey错误!"));
}
//有效期绝对值在30s以内
if (!(nowTimestamp - timestamp <= 30 && timestamp - nowTimestamp >= -30))
{
result = Json(RongboResult<bool>.Failed(-1, "时间戳timestamp参数过期,有效期为30秒!"));
}
var appSecret = AppSetting.CommonAPISecret();
var validationSign = MD5Helper.GetMD5_Utf8(appSecret + timestamp);
if (validationSign != sign)
{
result = Json(RongboResult<bool>.Failed(-1, "sign错误!"));
}
return result;
}
06-29
56万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)