/// <summary> /// Serialize a MacParams class /// </summary> /// /// <param name="MacObj">A MacParams class</param> /// /// <returns>A stream containing the MacParams data</returns> public static Stream Serialize(MacParams MacObj) { MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); writer.Write(MacObj.Key != null ? (short)MacObj.Key.Length : (short)0); writer.Write(MacObj.Salt != null ? (short)MacObj.Salt.Length : (short)0); writer.Write(MacObj.Info != null ? (short)MacObj.Info.Length : (short)0); if (MacObj.Key != null) { writer.Write(MacObj.Key); } if (MacObj.Salt != null) { writer.Write(MacObj.Salt); } if (MacObj.Info != null) { writer.Write(MacObj.Info); } stream.Seek(0, SeekOrigin.Begin); return(stream); }
/// <summary> /// Compare this MacParams instance with another /// </summary> /// /// <param name="Obj">MacParams to compare</param> /// /// <returns>Returns true if equal</returns> public bool Equals(MacParams Obj) { if (!Compare.IsEqual(Obj.Key, m_Key)) { return(false); } if (!Compare.IsEqual(Obj.Salt, m_Salt)) { return(false); } if (!Compare.IsEqual(Obj.Info, m_Info)) { return(false); } return(true); }