/// <summary> /// 核对签名 /// </summary> /// <returns></returns> public bool CheckSign(out string errMsg) { if (string.IsNullOrWhiteSpace(RsaKey)) { errMsg = "rsaKey is null."; return(false); } if (string.IsNullOrWhiteSpace(Ciphertext)) { errMsg = "ciphertext is null."; return(false); } if (Timestamp == 0) { errMsg = "timestamp is null."; return(false); } if (string.IsNullOrWhiteSpace(Sign)) { errMsg = "sign is null."; return(false); } //var st = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Timestamp); //if (Math.Abs(st.Days) >= 1) { errMsg = "timestamp is error."; return false; } var txt = $"{Ciphertext.ToSafeString()}|{RsaKey.ToSafeString()}|{Timestamp.ToSafeString()}"; var hash = HashUtil.GetMd5String(txt); if (Sign.ToUpper() != hash) { errMsg = "sign is error."; return(false); } errMsg = null; return(true); }