Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. drawing;
Using system. Drawing. imaging;
Using system. runtime. interopservices;
/// <Summary>
/// Compare byte arrays with memcmp
/// </Summary>
/// <Param name = "B1"> byte array 1 </param>
/// <Param name = "B2"> byte array 2 </param>
/// <Returns> If the two arrays are the same, 0 is returned. If array 1 is smaller than array 2, a value smaller than 0 is returned. If array 1 is greater than array 2, a value greater than 0 is returned. </Returns>
Public static int memorycompare (byte [] B1, byte [] B2)
{
Intptr retval = memcmp (B1, B2, new intptr (b1.length ));
Return retval. toint32 ();
}
/// <Summary>
/// Compare byte Arrays
/// </Summary>
/// <Param name = "B1"> byte array 1 </param>
/// <Param name = "B2"> byte array 2 </param>
/// <Returns> If the two arrays are the same, 0 is returned. If array 1 is smaller than array 2, a value smaller than 0 is returned. If array 1 is greater than array 2, a value greater than 0 is returned. </Returns>
Public static int memorycompare2 (byte [] B1, byte [] B2)
{
Int result = 0;
If (b1.length! = B2.length)
Result = b1.length-b2.length;
Else
{
For (INT I = 0; I <b1.length; I ++)
{
If (b1 [I]! = B2 [I])
{
Result = (INT) (b1 [I]-B2 [I]);
Break;
}
}
}
Return result;
}
/// <Summary>
/// Memcmp API
/// </Summary>
/// <Param name = "B1"> byte array 1 </param>
/// <Param name = "B2"> byte array 2 </param>
/// <Returns> If the two arrays are the same, 0 is returned. If array 1 is smaller than array 2, a value smaller than 0 is returned. If array 1 is greater than array 2, a value greater than 0 is returned. </Returns>
[Dllimport ("msvcrt. dll")]
Private Static extern intptr memcmp (byte [] B1, byte [] B2, intptr count );
}