/// <summary> /// Creates the MD5 based on the metadata of an attachment /// </summary> /// <param name="name"></param> /// <param name="comment"></param> /// <param name="displayName"></param> /// <param name="fileSize"></param> /// <returns></returns> public static byte[] HashAttachmentMetadata( string name, string comment, string displayName, long fileSize) { MD5Producer hashProducer = new MD5Producer(); StringBuilder sb = new StringBuilder(name.Trim()); sb.Append(comment.Trim()); sb.Append(displayName.Trim()); sb.Append(fileSize.ToString()); return(hashProducer.CalculateMD5(new MemoryStream(ASCIIEncoding.Default.GetBytes(sb.ToString())))); }
public bool CompareDocHash(XmlDocument xmlDocument, byte[] oldDocHash, ref byte[] newDocHash) { if (!m_md5Producer.Md5ProviderDisabled) { string docContent = xmlDocument.OuterXml; newDocHash = m_md5Producer.CalculateMD5(new MemoryStream(ASCIIEncoding.Default.GetBytes(docContent))); if (oldDocHash.Length > 0 && newDocHash.Length > 0 && 0 == m_md5Producer.CompareMD5(oldDocHash, newDocHash)) { return(true); } } return(false); }